Missinglinq, this is close. Two issues: I am getting a variable not defined for the Cancel = True. I removed the Cancel = True just to see if the rest works and it does. As soon as the form opens the msgbox pops up. I think that has to do with the VBA code I have to make the textbox go to the next record upon loading.
Changing event to before update instead of on Enter gives a "Procedure or declaration does not match description of event or procedure having the same name"
Below is all of the code.
Code:
Option Explicit
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub
Private Sub Order_Number_Enter()
If DCount("*", "Ready for Pickup", "[Order_Number] = '" & Me.Order_Number & "'") < 1 Then
Cancel = True
Me.Undo
MsgBox "There is No Ready For Pickup Record for this Order Number!"
End If
End Sub
Edit:
I realized the order number is defined as text and used
Code:
Private Sub Order_Number_BeforeUpdate(Cancel As Integer)
If DCount("*", "Ready for Pickup", "[Order_Number] = '" & Me.Order_Number & "'") < 1 Then
Cancel = True
Me.Undo
MsgBox "There is No Ready For Pickup Record for this Order Number!"
End If
End Sub
But this does nothing, it allows me to add anything. The format of the order number is "WEB0000000" if that matters