Using variables with RunSQL method

  • Thread starter Thread starter Del
  • Start date Start date
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?
 
DoCmd.RunSQL "UPDATE " & variable & _
"Set Field1 = 1;"

You may also be able to reference forms directly:

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

(david)
 
Back
Top