I have used DAO exclusively and I'm trying to learn ADO, but I'm having a bit of trouble simply creating a recordset based on a SQL statement. Here's the public function I created to test:
Public Function TestUser()
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenStatic
rst.LockType = adLockOptimistic
rst.Source = "SELECT * FROM tUsers WHERE tUsers.UserID = 5"
rst.Open Options:=adCmdText
If rst.RecordCount > 0 Then
Do Until rst.EOF
Debug.Print rst.Fields("Username")
rst.MoveNext
Loop
End If
rst.Close
Set rst = Nothing
End Function
The error message I receive at the "rst.open" line in the code is "No value given for one or more required parameters."
Any suggestions?
THANKS!
Public Function TestUser()
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenStatic
rst.LockType = adLockOptimistic
rst.Source = "SELECT * FROM tUsers WHERE tUsers.UserID = 5"
rst.Open Options:=adCmdText
If rst.RecordCount > 0 Then
Do Until rst.EOF
Debug.Print rst.Fields("Username")
rst.MoveNext
Loop
End If
rst.Close
Set rst = Nothing
End Function
The error message I receive at the "rst.open" line in the code is "No value given for one or more required parameters."
Any suggestions?
THANKS!