How to break syntax into multiple lines

sohailcdc

Registered User.
Local time
Today, 05:02
Joined
Sep 25, 2012
Messages
55
Hi there
Thanks for your help in advance

I search over the form and learn how to create the simple Update query in VBA, BUT
I am unable to break the UPDATE statement into multiple lines and now I am getting "Syntax Error in UPDATE statement"

Following is the multiple line Update Statement

Dim strsql As String
strsql = "Update tblcurr" & _
"SET tblCurr.Currencyname =" & _
"[forms]![updatecurrency]![txtcurname]" & _
"WHERE (((tblCurr.Currencycode)=" & _
"[forms]![updatecurrency]![txtcurcode]));"
DoCmd.RunSQL strsql

Following is the one liner Update statement which, works perfectly

strsql = "UPDATE tblCurr SET tblCurr.Currencyname = [forms]![updatecurrency]![txtcurname] WHERE (((tblCurr.Currencycode)=[forms]![updatecurrency]![txtcurcode]));"

Have a good one
 
Check your spaces.

Easiest way in testing is to have the procedure print the string to the immediate window rather than running it. That way you can look at the final product.
 
Finally I learn something new today, which make my day
Thanks to all
Be happy alway
 
This is a better way to format:

Code:
strsql = "Update tblcurr" _
       & " SET tblCurr.Currencyname =" _
       & " [forms]![updatecurrency]![txtcurname]" _
       & " WHERE (((tblCurr.Currencycode)=" _
       & " [forms]![updatecurrency]![txtcurcode]));"

See how it clearly shows the spaces all in a single column.
 

Users who are viewing this thread

Back
Top Bottom