Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to stop exiting a form

Status
Not open for further replies.

cer5yc

Programmer
Sep 27, 2007
103
US
I need the following to run when the user tries to close the form:

If Me.opgProjectStatus = 2 And IsNull(txtDateClosed) Then
Dim MsgBox5 As Integer
MsgBox5 = MsgBox("You must enter a value for 'Date Closed' or Select 'Open' for Project Status", vbOKOnly)

Can someone tell me what event I need to tie it to (right now I have it tied to the form unload event and it's not working.

My end goal is the user can't save the information if the above condition exists.

Can someone tell me how to write please ... Thanks!
 
You can put an exit button the form and disable the close button. You can then put your code in the click event of the exit button.
 
Oh good idea - how do I disable the close button?
 
Is there a way to disable the close button for the database itself?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top