Passing values into a doCmd.RunSQL statetment

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

After assigning a value to a variable - for example

x = 12/12/2005

I am trying to pass this value into the where clause of the following

doCmd.RunSQL("UPDATE tblDates SET ColumnY = 1 WHERE ColumnZ = X")

The problem is what is the syntax to correctly pass the value into the
statement

any help/suggestions would be appreciated
 
Date values you should put in #
string values in quotes

so in your case it should be:

doCmd.RunSQL("UPDATE tblDates SET ColumnY = 1 WHERE ColumnZ = #" & x & "#")
 
Alex said:
Date values you should put in #
string values in quotes

so in your case it should be:

doCmd.RunSQL("UPDATE tblDates SET ColumnY = 1 WHERE ColumnZ = #" & x & "#")
Be sure to format the date in US order: mm/dd/yyyy
 
Back
Top