SQL VBA Where Clause Issue

thescottsman

Registered User.
Local time
Today, 14:36
Joined
Sep 18, 2014
Messages
42
Hi All

I have done this before but having a blank moment. I have constructed this vba sqk statement and it will not work. I believe it is due to the WHERE Clause.

Can anyone see any issues with it?

UpdateOrderSQL = "UPDATE tbltest " & _
"SET [Supplier]='" & Me.Supplier & "',
"WHERE [OrderNumber]='" & Me.OrderNumber & "' AND [PartNumber]='" & Me.PartNumber & "' "

Thanks for your help
 
Surely you want to set the supplier to me.supplier
 
looks like you are missing a double quote and ampersand at the end of the SET line and a space before the WHERE

Also all are being treated as strings - is this correct?
 
Hi

That is what it is doing

It just I want to update the supplier for the order number and the part number in the table
 
also looks like you have a superfluous comma at the end of the SET line
 
You'll need to post up exactly what you've used. Put it in code tags don't re-type it, copy and paste it.
And as already asked are Where values text or numeric ?
 
You also are missing the closing semicolon at the end of your SQL statement.
 
You also are missing the closing semicolon at the end of your SQL statement.

The semicolon is optional for single commands, which is all Access can process anyway.
 
Do a Debug.Print of the command string after the concatenation of the variables. The errors usually become obvious.
 
The semicolon is optional for single commands, which is all Access can process anyway.

In my experience, some versions handle that more gracefully than others and it's better to be prepared for the stricter case. YMMV.
 
Do a Debug.Print of the command string after the concatenation of the variables. The errors usually become obvious.

In this case, it will likely show a missing space before WHERE, which is the most likely cause of the trouble.

Best,
Jiri
 

Users who are viewing this thread

Back
Top Bottom