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

Syntax error into Insert Statement

Status
Not open for further replies.

starclassic

Technical User
May 24, 2007
27
US
DoCmd.RunSQL "INSERT INTO tblDraftEntry (FormIDEntry,COCodeEntry,BeginEntry,EndingEntry,Date) Values" _
& "('" & Me.cboFormNumber & "', '" & Me.txtCode & "', " _
& "'" & Beginning & "', '" & Ending & "', '" & Format(Now(), "mm/dd/yyyy") & "')"

Not sure where the syntax error as it worked fine on my other programs, seems to be pointing on the Format(now(), "mm/dd/yyyy").

Thanks for the help.
 
The delimiter for dates is hash (#) not apostrophe (').
 
Dates should be incapsulated in # not ' in JET sql.

#" & Format(Now(), 'mm/dd/yyyy') & "#,'" &
 
DoCmd.RunSQL "INSERT INTO tblDraftEntry (FormIDEntry,COCodeEntry,BeginEntry,EndingEntry,Date) Values" _
& "('" & Me.cboFormNumber & "', '" & Me.txtCode & "', " _
& "'" & Beginning & "', '" & Ending & "', #" & Format(Now(), "mm/dd/yyyy") & "#)"
Its still get me the same error.
 
Numbers do not require delimiters. Date is a reserved word and should not be used as a field name, if it is used, it ought to be bracketed: [Date]
 
Thanks Remou,

I change the date field on table to DateToday and works fine now.

Thanks
Again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top