Help with Update query SQL

A

Alex

I'm trying to update the AllNewParts tbl with fields from the ExcelARefParts
tbl (I know I shouldn't be duplicating fields, but it's necessary in this
db.) I would greatly appreciate it if someone please help me with my syntax?
Thanks.

CurrentDb.Execute "UPDATE AllNewParts SET AllNewParts.RefPartNHL =
ExcelARefParts.AS Part#" & _
"WHERE AllNewParts.RefPart = ExcelARefParts.Part#" & _
"AND ExcelARefParts.Part# <> ExcelARfParts.AS Part#" & _
"AND ExcelARefParts.Variable > 0;"
 
J

Jeff L

"UPDATE AllNewParts Inner Join ExcelARefParts On AllNewParts.RefPart =
ExcelARefParts.Part#" & _
"SET AllNewParts.RefPartNHL = ExcelARefParts.[AS Part#]" & _
"WHERE ExcelARefParts.Part# <> ExcelARefParts.[AS Part#]" & _
"AND ExcelARefParts.Variable > 0;"
 
J

John Vinson

I'm trying to update the AllNewParts tbl with fields from the ExcelARefParts
tbl (I know I shouldn't be duplicating fields, but it's necessary in this
db.) I would greatly appreciate it if someone please help me with my syntax?
Thanks.

CurrentDb.Execute "UPDATE AllNewParts SET AllNewParts.RefPartNHL =
ExcelARefParts.AS Part#" & _
"WHERE AllNewParts.RefPart = ExcelARefParts.Part#" & _
"AND ExcelARefParts.Part# <> ExcelARfParts.AS Part#" & _
"AND ExcelARefParts.Variable > 0;"

Whenever you have special characters such as blanks - or, probably, #
as well - in a fieldname you must delimit the fieldname with [square
brackets].

Try

CurrentDb.Execute "UPDATE AllNewParts
SET AllNewParts.RefPartNHL = ExcelARefParts.[AS Part#]" & _
"WHERE AllNewParts.RefPart = ExcelARefParts.[Part#]" & _
"AND ExcelARefParts.[Part#] <> ExcelARfParts.[AS Part#]" & _
"AND ExcelARefParts.Variable > 0;"


John W. Vinson[MVP]
 

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

Update query in code syntax help 1
Unmatched record query help 5
Update value to null 1
Update Query Help 1
sql delete syntax 1
sql syntax error 2
Calculation in Update query drops decimal places 2
query too slow 1

Top