Syntax error INSERT INTO statement VBA

Ihussein

Registered User.
Local time
Today, 17:18
Joined
Nov 11, 2015
Messages
47
I'm using the following code to import data from external access DB but is showing syntax error INSERT INTO statement. any suggestions please. I'm calling the below code using cmd click event. Thanks

Private Sub ImportSelectedFile()
Dim strImportedData As String

strImportedData = "INSERT INTO tblRedeemedDatatmp ( RC_IDFK, VSN, DateOfPurchase, TraderCode_FK, Total, NoBeneCardNb," & _
"NoBeneSign, NoDateOfPurchase, NoTraderSign, DEName_FK, DateOfEntry, Dat )" & _
"NoBeneSign,NoDateOfPurchase,NoTraderSign,DEName_FK,DateOfEntry,Dat" & _
"SELECT Card_No, VSN,Purchase_Date,Trader_Code,Total,No_Beneficiary_Card_No,No_Beneficiary_Card_Sign," & _
"No_Date_of_Purchase,No_Traders_Sign, EntrName, EntrDate, Dat FROM red IN '" & vrtSelectedFile & "';"


DoCmd.RunSQL strImportedData
End Sub
 
Put a break on the docmd,
When vb stops there, type this in debug, to see the error,

?strImportedData
 
All right, thanks I will give it a try.
Best Regards
 
...

strImportedData = "INSERT INTO tblRedeemedDatatmp ( RC_IDFK, VSN, DateOfPurchase, TraderCode_FK, Total, NoBeneCardNb," & _
"NoBeneSign, NoDateOfPurchase, NoTraderSign, DEName_FK, DateOfEntry, Dat )" & _
"NoBeneSign,NoDateOfPurchase,NoTraderSign,DEName_FK,DateOfEntry,Dat" & _
"
You've two line of the same, I would also suggest you to put a space after "Dat ) ".
 
Thanks everyone I have re-write the SQL and it is working now.
Regards
 

Users who are viewing this thread

Back
Top Bottom