Skip to content
Advertisement

Error 424 object required after NULL SQL query

I am running some EXCEL VBA code to update the contents of an ACCESS database table along the lines suggested here: IF @@Rowcount = 0 — SQL Syntax Error in Access . When I execute the SELECT query, EXCEL VBA gives this error message:

I extracted the SQL string from the VBA Watch window and ran it as a Query in ACCESS. The first time I did this, there were no records becasue the table was empty, so I ran the INSERT query in ACCESS and then tried running the VBA code but got the same error message.

The code is here:

I am guessing that there is something wrong with the SQL SELECT string. I tried setting this directly using

but still get the same error message. I have also tried removing the colon …

Advertisement

Answer

The problem lies with the statement

If I change this to

then everything is fine. Should have scrolled to the end of the answer at the original link ….

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement