Using variables with RunSQL method

D

Del

This code works fine:

DoCmd.RunSQL "UPDATE Table1 " & _
"Set Field1 = 1;"

I want to use it for multiple tables so I'd like to assign the table name to
a variable and use the variable in the clause, but I can't get it to work.

DoCmd.RunSQL "UPDATE (variable here) " & _
"Set Field1 = 1;"

What is the syntax for this?
 
G

Guest

DoCmd.RunSQL "UPDATE " & variable & _
"Set Field1 = 1;"

You may also be able to reference forms directly:

DoCmd.RunSQL "UPDATE Forms!myform!myctrl " & _

(david)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top