prevent form from closing IF

  • Thread starter Thread starter deb
  • Start date Start date
D

deb

How can I prevent a form from closing if the "ProjEnd" date field <
"ProjStart" date field. I need to prompt user that they cannot close if the
"ProjEnd" date < "ProjStart" date.

I do not have a close button. I use the File, Close in the menu.

Thanks
 
Use the forms Unload event;

Private Sub Form_Unload(Cancel As Integer)

If Me![ProjEnd] < Me![ProjStart] Then
MsgBox "The end cannot come before the beginning"
Cancel = True
Me![ProjEnd].SetFocus
End If

End Sub
 
Back
Top