sanders720
Programmer
I would like to go into a form and change the data, but prior to doing this I would like to remember the old data and store it into a field. I am doing both a select and an update query here, but I'm not sure this is the correct approach or syntax. Certainly, I could just reat the form field txtQTY into the field OldQtyFlag.
Additionally, I am slightly confused as to which function to perform this command under. Got Focus, Change, etc. Do you know if there is a good reference for the exactness of when these events occur.
Private Sub txtQTY_GotFocus()
Dim db As Database
Dim sql As String
Dim rst As Recordset
Dim xQTY As Integer
'sql = "UPDATE tblBOM SET OldQtyFlag = " & numQTY & " WHERE JobNo = " & Me.JobNo.Value & " AND SubAssy= '" & Me.SubAssy.Value & "' and PartNo = '" & Me.PartNo.Value & "'"
sql = "SELECT QTY FROM tblBOM WHERE JobNo = " & Me.JobNo.Value & " AND SubAssy= '" & Me.SubAssy.Value & "' and PartMo = '" & Me.PartNo.Value & "'"
Set rst = CurrentDb.OpenRecordset(sql)
xQTY = rst("QTY"
With rst
db.Execute "UPDATE tblBOM SET OldQtyFlag = xQTY"
End With
rst.Close
Set rst = Nothing
End Sub
Additionally, I am slightly confused as to which function to perform this command under. Got Focus, Change, etc. Do you know if there is a good reference for the exactness of when these events occur.
Private Sub txtQTY_GotFocus()
Dim db As Database
Dim sql As String
Dim rst As Recordset
Dim xQTY As Integer
'sql = "UPDATE tblBOM SET OldQtyFlag = " & numQTY & " WHERE JobNo = " & Me.JobNo.Value & " AND SubAssy= '" & Me.SubAssy.Value & "' and PartNo = '" & Me.PartNo.Value & "'"
sql = "SELECT QTY FROM tblBOM WHERE JobNo = " & Me.JobNo.Value & " AND SubAssy= '" & Me.SubAssy.Value & "' and PartMo = '" & Me.PartNo.Value & "'"
Set rst = CurrentDb.OpenRecordset(sql)
xQTY = rst("QTY"
With rst
db.Execute "UPDATE tblBOM SET OldQtyFlag = xQTY"
End With
rst.Close
Set rst = Nothing
End Sub