UPDATE SET Sql not working

charlesfchang

New member
Local time
Today, 10:37
Joined
Jun 18, 2013
Messages
6
Hello All,

I was planning to use the said commands above via vba. (UPDATE SET of SQL)

Code:
 DoCmd.SetWarnings False
    'adds the
    strSQL = "UPDATE tblCurrentOrder" & TblNum & _
             " SET Table = '" & TblNum & "', OrderNumber = '" & OrdNum & "';"
    DoCmd.RunSQL strSQL    

    DoCmd.SetWarnings True

but when i run the code, it give me a syntax error

in addition to this, tblnum and ordnum will be null before running the command.
 
You've confused me.
This
"UPDATE tblCurrentOrder" & TblNum
will concatenate the string tblCurrentOrder and the value of TblNum

eg suppose tblNum is 9
you will end up with tblCurrentOrder9 which I believe is not what you intended.

So start by including a trailing space in "UPDATE tblCurrentOrder "

Also, instead of turning warnings Off and ON, use the
Currentdb.execute sql,dbFailOnError command structure. You will get an error message if there is an error, but you won't get all of the prompts.

Good luck.
 

Users who are viewing this thread

Back
Top Bottom