Update query in code syntax help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to do an update in code but my syntax is wrong. Can someone tell
me how I'm writing this incorrectly? Thanks.

CurrentDb.Execute "UPDATE AllNewParts SET AllNewParts.RefPartEAU =
ExcelARefParts.Annual Qty" _
& "WHERE (((AllNewParts.RefPart) = ExcelARefParts.AS Part# AND
(AllNewParts.RefPartNHL) = ExcelARefParts.As Part# And
(ExcelARefParts.Model#) = AllNewParts.Model#));"
 
You must use square brackets around the field names that contain a space, #,
or any other characters that are not a digit, letter, or underscore (and
also if the field name starts with a digit.)

You were also missing a space before the WHERE.

CurrentDb.Execute "UPDATE AllNewParts SET AllNewParts.RefPartEAU =
ExcelARefParts.[Annual Qty]" _
& " WHERE (AllNewParts.RefPart = ExcelARefParts.[AS Part#]) AND
(AllNewParts.RefPartNHL = ExcelARefParts.[As Part#]) AND
(ExcelARefParts.[Model#] = AllNewParts.[Model#]);"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Help with Update query SQL 2
Update value to null 1
Unmatched record query help 5
Update Query Help 1
Delete button and refresh 8
sql delete syntax 1
Syntax Error 2
syntax help requested 1

Back
Top