I have a parts entry form that has text boxes for RO#, Inv# as well as others. Due to how we receive parts I COULD need to store the RO# and Inv# for use on the next entry. I accomplish this by using the AfterUpdate functionality with the code provided because I don't know any better. The code will store the RO#/Inv# in a corresponding string variable and I use the GotFocus function to auto-populate the RO#/Inv# with these values for the next record. The user can just hit enter to proceed through these fields with the supplied values or they can overtype the supplied values if they need to change either or both numbers. Now to my issue; all that seems to be working perfectly BUT when the user hits enter on the last field (and has no more parts to enter) the form writes to the table the stored value for the RO# creating an entry that is not needed or desired. How can I avoid thees "Ghost" entries? Also, the user will open and close the form as needed throughout the day creating several of these Ghost entries.
VBA Code:
'Form frmPartsEntry
Dim strRO As String
Dim strInv As String
Private Sub txtInvNum_GotFocus()
txtInvNum = strInv
End Sub
Private Sub txtRONum_AfterUpdate()
strRO = txtRONum
'Uncomment line below for debugging
'MsgBox "strRO = " & strRO, vbInformation, "Fix code if necessary."
End Sub
Private Sub txtInvNum_AfterUpdate()
'Convert all text in invoice to caps before writing to table
Me.txtInvNum = UCase(Me.txtInvNum)
'Retain invoice number for use on next entry
strInv = txtInvNum
'Uncomment line below for debugging
'MsgBox "strInv = " & strInv, vbInformation, "Fix code if necessary."
End Sub
Private Sub txtRONum_GotFocus()
txtRONum = strRO
End Sub