Inserting a date

N

nick

Simple huh?

The relevant field is Payment_Date. It's at the end of the insert-fields
list and the values list. Am I doing something syntactically wrong here?

DoCmd.RunSQL ("INSERT INTO Salary (Employee_ID, Base_Amt, Site_Allowance,
Deductions, Overtime_1, Overtime_2, Overtime_3, Bonus, Labour_Ins,
Income_Tax, Transportation, Incurred_Expenses, Credit_Rent, Other_Deductions,
Deductions_Reason, Tax_Refund, Confirmed, Logged_By, Payable, Payment_Date)"
& _
" Values (" & Employee_ID & _
", " & Base_Salary & _
", " & Site_Allowance & _
", " & Deductions & _
", " & Overtime_One & _
", " & Overtime_Two & _
", " & Overtime_Three & _
", " & Bonus & _
", " & Labour_Insurance & _
", " & Income_Tax & _
", " & Transportation & _
", " & Incurred_Expenses & _
", " & Credit_Rent & _
", " & Other_Deductions & _
", " & Chr$(34) & Deductions_Reasons & Chr$(34) & _
", " & Tax_Refund & _
", " & Chr$(34) & Confirmed & Chr$(34) & _
", " & User_ID & _
", " & Payable & _
", " & # & Payment_Date & # & ")")
 
A

Allen Browne

Yes, the hash marks need to go inside the quotes, to become part of the
string:
", #" & Payment_Date & "#)")
 
T

Tim Ferguson

Yes, the hash marks need to go inside the quotes, to become part of the
string:
", #" & Payment_Date & "#)")

If the Payment_Date is a DateTime variable, then you really need to control
the formatting, otherwise your first german temp who sets her regional
settings to a normal (ahem!) date format will kill the script dead.

", " & format(Payment_Date, "\#yyyy\-mm\-dd\#") & ")"


Hope that helps


Tim F
 

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