I have an unbound combo box on a form. I validate the field 'on exit' to ensure it is not null. If it is null I display an error message and then return to the field. This works well, until the close button or red x is entered. When either of these events occur, I want to skip the error checking and close the form.
Here is an example of the code I would like:
Private Sub unbPaymentType_Exit(Cancel As Integer)
' don't error check if close button or red x is pressed
if CloseButtonPressed = True or RedXPressed = True then
' if payment type is blank, can't exit
If Nz(Me.unbPaymentType, "") <= "" Then
MsgBox "You Must Select a Payment Type", vbOKOnly, "Invalid Payment Type"
Cancel = 1
of course the first if statement is not valid syntax, but you probably understand what I am after.
Seems simple, but I can't find any way to determine what caused the 'on exit' of my field.
Any help would be greatly appreciated.