SteveL13
asked on
How update field in separate table when value in form changes
I have a form which has tblPartsMasters as its record source. When the vale in one of the fields on the form changes I want that value written to a field in a separate table. Basically this is what I'm trying to accomplish. I need help figuring out what the after update event of the field on the form should be...
On afterupdate event of field “txtPatt_Loc” (control source is [Patt_Loc] in “tblPartsMasters”) on “frmJobCards” update
The field [Patt_Loc] in “tblOpenOrders”
Where
[Part_No] = “txtPartN” on “frmJobCards”
--Steve
On afterupdate event of field “txtPatt_Loc” (control source is [Patt_Loc] in “tblPartsMasters”) on “frmJobCards” update
The field [Patt_Loc] in “tblOpenOrders”
Where
[Part_No] = “txtPartN” on “frmJobCards”
--Steve
ASKER
Yes, both fields are text. But as usual, I forgot to mention one thing. I am sorry. When the update happens it needs to update all records in the tblOpenOrders where the Part_No is the same AND a Yes/No field named "Complete" is false.
Can you help a little more?
Can you help a little more?
Just add it on to the WHERE clause:
Alternatively:
DIM strSQL as String
strSQL = "UPDATE tblOpenOrders SET [Patt_Loc] = " & chr(34) & Me.txtPatt_Loc & chr (34) & " WHERE [Part_No] = " & chr(34) Me.txtPartN & chr(34) & " AND Complete = 0 "
CurrentDB.Execute strSQL, dbFailOnError
Alternatively:
DIM strSQL as String
strSQL = "UPDATE tblOpenOrders SET [Patt_Loc] = " & chr(34) & Me.txtPatt_Loc & chr (34) & " WHERE [Part_No] = " & chr(34) Me.txtPartN & chr(34) & " AND Complete = FALSE "
CurrentDB.Execute strSQL, dbFailOnError
ASKER
When I copy/paste this line...
strSQL = "UPDATE tblOpenOrders SET [Patt_Loc] = " & chr(34) & Me.txtPatt_Loc & chr (34) & " WHERE [Part_No] = " & chr(34) Me.txtPartN & chr(34) & " AND Complete = FALSE "
it turns red.
??
strSQL = "UPDATE tblOpenOrders SET [Patt_Loc] = " & chr(34) & Me.txtPatt_Loc & chr (34) & " WHERE [Part_No] = " & chr(34) Me.txtPartN & chr(34) & " AND Complete = FALSE "
it turns red.
??
ASKER
A message pops up...
Compile Error: Expected: End of statement
Compile Error: Expected: End of statement
It should all be on one line...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect. Thanks!
:)
Glad to help
Glad to help
Open in new window
I'm assuming that both Patt_Loc and Part_No are text. If either is numeric, drop the surrounding chr(34)'s