What is wrong with this code?

  • Thread starter Thread starter Ivan
  • Start date Start date
I

Ivan

Hello,

in the Access 2003 mdb I used thise code to open a (stored) select query
qrySomeName as a recordset:

Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.Source = "qrySomeName"
rst.LockType = adLockOptimistic
rst.CursorType = adOpenForwardOnly
rst.Open

After I moved to Access 2007 I am geting but the error with description:
"Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT',
or 'UPDATE'.

What is wrong with my code?

Ivan
 
I would expect that it is a problem with your query. Can you tell me
what your query code is?
 
I found the reason for the error. Before converting to A2007 I have also
changed some date criteria in my query so that it was dependent on textbox
of the form. I coud open the query but the query was not OK for the VB. I
had later also problems with international date format which is not allowed
in VB (in VB you must use United States date format!) . To avoid such
problem I writed later SQL statement directly into the code so that I
translate my non US date format.

Ivan
 
Back
Top