Problems (Syntax Error) with SQL statement

greenguy

Registered User.
Local time
Today, 02:54
Joined
Oct 30, 2007
Messages
36
Howdy, I'm trying to send information to a table that the user wants deleted. I just want to make sure I save the data to a different table before he/she deletes it. I keep getting a syntax error but I'm not even sure if I can perform the transaction the way I'm doing it. If anyone can give me a pointer I'd appreciate it!!


'Need to send the information to the deleted table
strSQL = "INSERT INTO tbldeletedinfo([INCR],[Date Entered],[Planner],[BU],[Material Number],[Material Description],"
strSQL = strSQL & "[Quantity],[PO Number],[Supplier],[Reason][Approver],[Comments],[Cost],[Type],[Cost Center],"
strSQL = strSQL & "[Mode],[Prepaid/Collect])"
strSQL = strSQL & " SELECT " _
& "[tblhistory].[INCR]," _
& "[tblhistory].[Date Entered]," _
& "[tblhistory].[Planner]," _
& "[tblhistory].[BU]," _
& "[tblhistory].[Material Number]," _
& "[tblhistory].[Material Description]," _
& "[tblhistory].[Quantity]," _
& "[tblhistory].[PO Number]," _
& "[tblhistory].[Supplier]," _
& "[tblhistory].[Reason]," _
& "[tblhistory].[Approver]," _
& "[tblhistory].[Comments]," _
& "[tblhistory].[Cost]," _
& "[tblhistory].[Type]," _
& "[tblhistory].[Cost Center]," _
& "[tblhistory].[Mode]," _
& "[tblhistory].[Prepaid/Collect]" _
& " FROM tblhistory WHERE([INCR]=" & lngResult & ");"
MsgBox strSQL
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
 
Add a space after the word WHERE and see if that's it.
 
Hey Paul, nope still getting a Syntax error. Thanks for the reply!
 
Hi -

It appears that, in some cases, you've used commas where periods are required, e.g.

[INCR],[Date Entered] versus [INCR].[Date Entered]

Try cleaning those up and see if that eliminates the error(s).

Bob
 
Found the problem, I was missing a comma between the two fields.
],[Reason][Approver],[

Thanks for the responses though!
 

Users who are viewing this thread

Back
Top Bottom