Passing values into a doCmd.RunSQL statetment

M

Mike

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
 
A

Alex Dybenko

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 & "#")
 
B

Bas Cost Budde

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
 

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