firefly2k8
Registered User.
- Local time
- Today, 08:56
- Joined
- Nov 18, 2010
- Messages
- 48
Hi,
I have created a database with a table. I am trying to access some records using the VBE and print them to the immediate window. Trying to do it properly so followed this code from a book. But it just gives me a runtime error. Any ideas?
I have created a database with a table. I am trying to access some records using the VBE and print them to the immediate window. Trying to do it properly so followed this code from a book. But it just gives me a runtime error. Any ideas?
Code:
Private Sub Command0_Click()
Dim rst1 As ADODB.Recordset
'Create Recordset reference and set its properties
Set rst1 = New ADODB.Recordset
rst1.CursorType = adOpenKeyset
rst1.LockType = adLockOptimistic
'Open recordset, print test record
rst1.Open "PID:6", "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\example folder\MyProject.mdb;"
Debug.Print rst1.Fields(0).Value, rst1.Fields(1).Value
'Clean up objects
rst1.Close
Set rst1 = Nothing
End Sub