UPDATE query not working with date value

stringman

Registered User.
Local time
Today, 03:56
Joined
Oct 5, 2006
Messages
24
Hello,

I am having a problem w/ my UPDATE statement when the date value is included in the statement. I have tried surrounding the date variable (strDate) in "#" and w/ and w/out single quotes to no avail. I doesn't matter if I dimension strDate as a string or a date. I know there must be a simple solution. In short, the UPDATE statement looks like this:

Code:
strSQL = "UPDATE tblTasks SET POC = '" & strPOC & "', Date = #" & strDate & "#, Task = '" & strTask & "' WHERE id = " & lID & ";"

If I remove
Code:
Date = #" & strDate & "#,
then the query works.

These also fail:
Code:
Date = #'" & strDate & "'#,
Code:
Date = '#" & strDate & "#',
Code:
Date = '" & strDate & "',

Any help would be greatly appreciated. Thanks.

Ken
 
strSQL = "UPDATE tblTasks SET POC = '" & strPOC & "', Date = #" & strDate & "#, Task = '" & strTask & "' WHERE id = " & lID & ";"

Date is a function name. It's better to use another name for the field though sometimes putting [Date] in a SQL statement works.

When you delimit strDate with the # signs, the date in strDate needs to be a text string in US date format i.e. m/d/yyyy or mm/dd/yyyy.

^
 
EMP,

I placed brackets around the Date field in the SQL statement and it worked like a charm. I knew it had to be something simple. No more fields named after Access function for me! Thanks.

Ken
 

Users who are viewing this thread

Back
Top Bottom