I've written code like this quite a few times, but all of a sudden this code is throwing an error message. The error message is this:
Run-time error '-2147217900 (80040x14)':
Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
The code generating this is as follows:
----------------------------------------------------------------------
Public Function test()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = CurrentProject.Connection
Set rst = New Recordset
rst.Open "Scrap Tickets", cnn, adOpenDynamic, adLockOptimistic
rst.MoveFirst
While Not rst.EOF
Debug.Print rst.Fields(0).Value
rst.MoveNext
Wend
rst.Close
Set rst = Nothing
Debug.Print "finished"
End Function
----------------------------------------------------------------------
The line: "rst.Open "Scrap Tickets", cnn, adOpenDynamic, adLockOptimistic" is what is generating the error message. "Scrap Tickets" is a table located in the same database that I am writing this module in.
I feel like I'm probably missing something very simple here, but I can't figure out what is going on, especially since this code is directly based off of working code I'd already written.
Anyone have any ideas?
Thanks in advance for your time!
Brooks Tilson
Database Development
Tilson Machine, Inc.
Run-time error '-2147217900 (80040x14)':
Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
The code generating this is as follows:
----------------------------------------------------------------------
Public Function test()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = CurrentProject.Connection
Set rst = New Recordset
rst.Open "Scrap Tickets", cnn, adOpenDynamic, adLockOptimistic
rst.MoveFirst
While Not rst.EOF
Debug.Print rst.Fields(0).Value
rst.MoveNext
Wend
rst.Close
Set rst = Nothing
Debug.Print "finished"
End Function
----------------------------------------------------------------------
The line: "rst.Open "Scrap Tickets", cnn, adOpenDynamic, adLockOptimistic" is what is generating the error message. "Scrap Tickets" is a table located in the same database that I am writing this module in.
I feel like I'm probably missing something very simple here, but I can't figure out what is going on, especially since this code is directly based off of working code I'd already written.
Anyone have any ideas?
Thanks in advance for your time!
Brooks Tilson
Database Development
Tilson Machine, Inc.