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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is this a Date format problem?

Status
Not open for further replies.

modalman

Programmer
Feb 14, 2001
156
GB
Hi. I have a form that with a few text boxes in Access 97. One of them is set to recieve a 'General Date'. When the button is clicked the following code tries to write the form fields to my db:

DoCmd.RunSQL ("INSERT INTO WageAccounts (WorkerID, Date, Earnt) VALUES(" & [WorkerID] & ", '" & [Date] & "', " & [Earnt] & ");")

This throws up an error but works perfect if the Date field is excluded. The db field is formatted as a Date field as well. Do I need something else in the SQL string to modify the Date before it goes to the db? Many thanks in advance. ASCII silly question, get a silly ANSI
 
DoCmd.RunSQL ("INSERT INTO WageAccounts (WorkerID, Date, Earnt) VALUES(' & [WorkerID] & ', #" & [Date] & "#, " & [Earnt] & ");")

The placeholders for a date are #, for a string ' and blank for a number.

Craig

 
Cheers Craig. I changed the field name from 'Date' to 'TransDate' and it started working. Seems like the SQL statement reserves the word Date. Its now putting an incorrect value into the db so hopefully your suggestion will sort that out. Thanks again
ASCII silly question, get a silly ANSI
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top