Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Now() function 1

Status
Not open for further replies.

Watermelon

Programmer
Apr 16, 2001
68
US
Hi,

I'm using the Now() function in an Access module to try to insert the current date and time into a date/time field in one of my tables. Everytime I try to run the code I get a "Syntax error in Insert statement." Here's my code:
sql = "INSERT INTO IPOClientDetails(ClientID, Date,ContactMethod)VALUES(" & rsNewOrders!ClientID & "," & Now() & "," & """Email""" & ")"

Does anyone have any idea what the problem is? Thanks for any help?
SGM
 
hi there,

try putting a space between ) and VALUES....


sql = "INSERT INTO IPOClientDetails(ClientID, Date,ContactMethod) VALUES(" & rsNewOrders!ClientID & "," & Now() & "," & """Email""" & ")"

:)

Cheers,
Dan
 
Hi Dan,

Thanks for the suggestion. I tried that out. Unfortunately, I'm still getting the same message. I'm pretty sure the problem is the Now() field because I don't get the error message when I comment out this field. But, I still don't know exactly what that problem is.

Watermelon
 
The date literal must be surrounded by # or ' after it is resolved depending on the database being used.

sql = "INSERT INTO IPOClientDetails(ClientID, Date,ContactMethod)VALUES(" & rsNewOrders!ClientID & ", #" & Now() & "#, " & """Email""" & ")"
 
Hi cmmrfds,

Thanks, bingo. That did it.

Watermelon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top