docmd.runsql - error 438 - object doesnt support this property or method

DanielR

Registered User.
Local time
Today, 15:11
Joined
Mar 16, 2018
Messages
72
Trying to run and insert statement using:
DoCmd.RunSQL insertSQL

I did msgbox insertSQL:
"INSERT INTO Notes ([Project ID], Status, Comment, [User Name])
VALUES (5, 'In Progress', 'This is a test', 'dr'); "

Not sure why I am getting this error?
 
It seems legal. (is notes the table name?)
put it in a query and run it.
Try to use queries instead of sql. (for just that reason)
 
Yes, "Notes" is the table name.
Your suggesting to use an update query instead of sql statements?
 
I created an Append query. How do I pass data from my form to the query:
DoCmd.OpenQuery "qryAppendNotes" ....
 
I tried to do:
DoCmd.OpenQuery insertSQL
where insert SQL is:
"INSERT INTO Notes ([Project ID], Status, Comment, [User Name])
VALUES (5, 'In Progress', 'This is a test', 'dr'); "
Still get the same error?
 
I can run the sql code in the query and I get no error messages
 
I tried to do:
DoCmd.OpenQuery insertSQL
where insert SQL is:
"INSERT INTO Notes ([Project ID], Status, Comment, [User Name])
VALUES (5, 'In Progress', 'This is a test', 'dr'); "
Still get the same error?

DoCmd.OpenQuery should be followed by the name of a query, not a SQL statement

Your code should be
Code:
DoCmd.RunSQL insertSQL
Or
Code:
CurrentDb.Execute insertSQL

Also have you defined insertSQL as a string?
 
Not sure if it helped...haven’t tested it yet.
Thank you for the assistance.
It is appreciated.
 

Users who are viewing this thread

Back
Top Bottom