I have this code in my form to check record source table PGACCOUNTS11510 for a duplicate entry in PTLU, which is a number - this number is entered from paperwork, which is always unique
Here, if they duplicate it, user should get a message and is returned to the field to enter a different number
tested not getting expected results:
Private Sub PTLU_BeforeUpdate(Cancel As Integer)
If DCount("*", "PGACCOUNTS11510", PTLU = Me.PTLU) > 0 Then
MsgBox Me.PTLU & " is already used!" & vbCrLf & vbCrLf & _
"Check account number and try again." & vbCrLf & _
Cancel = True
Me.Undo
Me.PTLU.SetFocus
End If
End Sub
This is triggering every time, if its a duplicate or not, with a msg box False
When I ok that msg I return to the form, and then a run-time 2108 you must save the field before you execute the GoToControl action , the GoToControl method, or the SetFocus method
The form goes blank and the record is not saved
Any ideas on where I went wrong?
Here, if they duplicate it, user should get a message and is returned to the field to enter a different number
tested not getting expected results:
Private Sub PTLU_BeforeUpdate(Cancel As Integer)
If DCount("*", "PGACCOUNTS11510", PTLU = Me.PTLU) > 0 Then
MsgBox Me.PTLU & " is already used!" & vbCrLf & vbCrLf & _
"Check account number and try again." & vbCrLf & _
Cancel = True
Me.Undo
Me.PTLU.SetFocus
End If
End Sub
This is triggering every time, if its a duplicate or not, with a msg box False
When I ok that msg I return to the form, and then a run-time 2108 you must save the field before you execute the GoToControl action , the GoToControl method, or the SetFocus method
The form goes blank and the record is not saved
Any ideas on where I went wrong?