dcbeere
10-20-2000, 05:05 PM
I am using a list box to display touples from an Access 2000 database. I am using an ADO control. The touples are displayed fine, but when one is clicked it does not pass the other attributes to other textboxes. It gets hung up on the OpenDatabase command, I get a run-time error (3343) that says that it is a unrecognized database format. The following code works perfectly using Access 97 and a DAO control. How can I make this work with Access 2000 and an ADO control?
Private Sub DataList1_Click()
Dim db As Database
Dim rs1 As Recordset
Dim s1 As String
cName = DataList1.Text
Set db = OpenDatabase("C:db1.mdb") 'ERROR IS HERE
s1 = "SELECT * FROM Table1 WHERE Table1.name = '" & cName & "'"
Set rs1 = db.OpenRecordset(s1)
zipCode = rs1("zip")
Text2.Text = zipCode
Set db = Nothing
End Sub
Private Sub DataList1_Click()
Dim db As Database
Dim rs1 As Recordset
Dim s1 As String
cName = DataList1.Text
Set db = OpenDatabase("C:db1.mdb") 'ERROR IS HERE
s1 = "SELECT * FROM Table1 WHERE Table1.name = '" & cName & "'"
Set rs1 = db.OpenRecordset(s1)
zipCode = rs1("zip")
Text2.Text = zipCode
Set db = Nothing
End Sub