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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stopping exit of database 2

Status
Not open for further replies.

DBAMJA

Programmer
Joined
Jul 25, 2003
Messages
169
Location
US
I know that this has been asked before and I have been trying to seach the treads for the information but I just can't seem to find what I am looking for.

I need to be able to stop the user from closing Access by using the x in the upper right hand corner of the screen. I know that it has to do with the cancel of a form in the unload event but I just can't seem to get what I am looking for.

If anyone could post some code for me or point me to some threads that have already covered this it would be greatly appreciated.

Again, sorry for the duplicate question.


DBAMJA

It is said that God will give you no more than you can handle. I just wish God didn't have so much faith in me.
 
To stop the user from exiting Access, you will need to set the Modal property and Pop Up property on your form to Yes.

To stop the user from closing the current form using the x there is a property in the form called Close Button.
Set this to No and it should disable the x to close the form.

Hope this helps you.
 
Thank you for that idea. Setting the form to modal should work just fine. Thanks.

DBAMJA

It is said that God will give you no more than you can handle. I just wish God didn't have so much faith in me.
 
I have another method that I prefer. I don't like modal because it makes debugging a PITA.

I put this in all of my main forms:

Private Sub Form_Unload(Cancel As Integer)
If Me!btnClose.Tag <> &quot;exit&quot; Then Cancel = True
End Sub

There's also a command button on the form labled &quot;Close&quot; or &quot;Cancel&quot; that first sets the tag of the close button and then closes the form. That makes the close button the only way to close the form.

It also means that the application can't be closed by clicking on the X, as the cancel of the Unload prevents this.

I also turn off the control box, min/max buttons and the close button, as well as making the border dialog for all of these forms.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top