Hello,
I'am trying to perform an update on my table based on the textboxes data; however, when the code is executed it generates a new record instead of updating.
The issue is this there are 2 ppl at the area:
here is the code I am working with:
I'am trying to perform an update on my table based on the textboxes data; however, when the code is executed it generates a new record instead of updating.
The issue is this there are 2 ppl at the area:
- either one of them can either start the log and/or edit the record created by the other person
- If the record exists we only want to edit the record without overwriting the existing data from previous person
- The query version of the attempt has the WHERE clause in it
- this was an old db attempt by someone else unfortunately I inherited it
- the WHERE clause comes from the data on a textbox but I can get it to work
here is the code I am working with:
Code:
Dim db As Database
Dim rec As Recordset
Set db = CurrentDb
'TRIED THE FOLLOWING AFTER A FEW TRIES, CAN NOT GET THE WHERE CLAUSE TO WORK?***********
GCriteria = "[LOG.Thermal_WorkOrder]=[Forms]![THERMALFrm]![Thermal_WorkOrder]"
Set rec = db.OpenRecordset("SELECT Thermal_WorkOrder , Thermal_MaterialNumber, Thermal_DateTime2, Thermal_Quantity2, Thermal_Operator2, Thermal_Reject2 FROM Log WHERE " & GCriteria)
rec.AddNew ' CHANGED THIS TO UPDATE AND DID NOT CHANGE THE OUTCOME
rec("Thermal_DateTime2") = Me.Thermal_DateTime2
rec("Thermal_WorkOrder") = Me.Thermal_WorkOrder
rec("Thermal_MaterialNumber") = Me.Thermal_MaterialNumber
rec("Thermal_Quantity2") = Me.Thermal_Quantity2
rec("Thermal_Operator2") = Me.Thermal_Operator2
rec("Thermal_Reject2") = Me.Thermal_Reject2
rec.Update
Set rec = Nothing
Set db = Nothing
'move to empty record
DoCmd.GoToRecord Record:=acNext
End If
Last edited: