Syntax Error in INSERT INTO statement

stevenblanc

Registered User.
Local time
Today, 02:18
Joined
Jun 27, 2011
Messages
103
Ladies and Gentlemen,

I am having the Title error everytime I attempt to execute my SQL string. I cannot for the life of me determine what is causing it. I recently added a new Column 'Currency' onto my table and as such updated my entry code to reflect it.

My SQL string before was as follows:

Code:
strSQL = "INSERT INTO tblReceipts (ReceiptDate, CustomerID, ReceivedFrom, InPaymentOf, AmountWords, Amount, Notes, CashChequeNo) Values ('" & strReceiptDate & "','" & strCustomerID & "','" & strReceivedFrom & "','" & strInPaymentOf & "','" & strAmountWords & "','" & strAmount & "','" & strNotes & "','" & strCashChequeNo & "')"

Which produced the following output:

INSERT INTO tblReceipts (ReceiptDate, CustomerID, ReceivedFrom, InPaymentOf, AmountWords, Amount, Notes, CashChequeNo) Values ('6/8/2011','556556','53645645','6456456','Five Hundred Sixty Dollars and No Cents','560','gfnfgnfgn','cash')

with no errors. However upon adding currency to my code:

Code:
strSQL = "INSERT INTO tblReceipts (ReceiptDate, CustomerID, ReceivedFrom, InPaymentOf, AmountWords, Amount, Notes, CashChequeNo, Currency) Values ('" & strReceiptDate & "','" & strCustomerID & "','" & strReceivedFrom & "','" & strInPaymentOf & "','" & strAmountWords & "','" & strAmount & "','" & strNotes & "','" & strCashChequeNo & "','" & strCurrency & "')"

resulting in the following output:

INSERT INTO tblReceipts (ReceiptDate, CustomerID, ReceivedFrom, InPaymentOf, AmountWords, Amount, Notes, CashChequeNo, Currency) Values ('6/8/2011','556556','53645645','6456456','Five Hundred Sixty Dollars and No Cents','560','gfnfgnfgn','cash','2')

and the Syntax Error in INSERT INTO statement.

Initially I had the 'Currency' column set to Number and used intCurrency. I have since converted to strCurrency and changed the column type to Text to no avail.

Any input would be greatly appreciated.

Regards,


Steven
 
Having a field named Currency might be causing problems
It is the name of a field type

Why you would change it to a Text field I can;t imagine
 
It was that simple. Changed to 'CurrencyCode' and it was good to go.

Thank you. As for the change to text I had reached my wits end.
 
I know the feeling. Lots of strange designs come from that place ;)
 

Users who are viewing this thread

Back
Top Bottom