prevent form from closing IF

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
 
B

Beetle

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top