Using the code you've posted, I can't reproduce the error, even while closing on a New Record. By the time you get to the Form_Unload event the last Record you were on has already been saved. Checking for this kind of thing is normally done in the Form_BeforeUpdate event; if you can't save the Record you can't close the Form. Also, if you enter more than one Record, alpha > beta could be true for one Record but not for the last Record entered, and it wouldn't be caught with code in Form_Unload.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.alpha > Me.beta then
Msgbox "Message---etc"
Cancel =True
End Sub
If you're running more than one validation you need to add a line to Exit the Sub after a given test fails, otherwise Access will just keep 'dropping through' to the next test:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.alpha > Me.beta then
Msgbox "Message---etc"
Cancel =True
Exit Sub
End Sub
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007