Need a little assistance with a VBA code for updating tables through a form. I have a form with two text boxes and a command button. One text box is named txtNewPartNumbe r and the other text box is named txtOldPartNumbe r. The idea is for the user to type in the old part number in the txtOldPartNumbe r box and type what the new part number is changing to into the txtNewPartNumbe r box then click on the command button to change the part numbers in 3 different tables. When I set up the VBA code to change the part number in one table, it works just fine, but when I try to and another table, I get the error message shown below. What am I missing in the SQL statement?

Here is the code I am using to update the tables
Private Sub cmdUpdate_Click ()
Dim mySQL As String
mySQL = "UPDATE tblPreventiveTo olDamageinfo, tblPMTrial"
mySQL = mySQL + " SET tblPMTrial.Part Number = '" & Me.txtNewPartNu mber & "' tblPreventiveTo olDamageinfo.Pa rtNumber = '" & Me.txtNewPartNu mber & "'"
mySQL = mySQL + " WHERE tblPMTrial.Part Number = '" & Me.txtOldPartNu mber & "' AND tblPreventiveTo olDamageinfo.Pa rtNumber = '" & Me.txtOldPartNu mber & "'"
DoCmd.RunSQL mySQL
cmbPartNumber.R equery
End Sub
Thanks for your help

Here is the code I am using to update the tables
Private Sub cmdUpdate_Click ()
Dim mySQL As String
mySQL = "UPDATE tblPreventiveTo olDamageinfo, tblPMTrial"
mySQL = mySQL + " SET tblPMTrial.Part Number = '" & Me.txtNewPartNu mber & "' tblPreventiveTo olDamageinfo.Pa rtNumber = '" & Me.txtNewPartNu mber & "'"
mySQL = mySQL + " WHERE tblPMTrial.Part Number = '" & Me.txtOldPartNu mber & "' AND tblPreventiveTo olDamageinfo.Pa rtNumber = '" & Me.txtOldPartNu mber & "'"
DoCmd.RunSQL mySQL
cmbPartNumber.R equery
End Sub
Thanks for your help
Comment