Update query in code syntax help

A

Alex

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#));"
 
A

Allen Browne

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

Top