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

Disable Access main window close button? 2

Status
Not open for further replies.

dejfatman

Programmer
Jan 24, 2002
34
US
Is there a way to disable the close button on the Access application itself so the application can only be terminated using the 'quit' button I provided?
 
yep

Private Sub Form_Unload(Cancel As Integer)
Cancel = True
End Sub


that won't let you close it at all, short of ctrl-alt-del. You will want to have a flag in there that will let it close when you hit the delete button, like this:

Private Sub Form_Unload(Cancel As Integer)
if (canClose = false) then
Cancel = True
else
Cancel = False
end if
End Sub


then have your button make the global variable canClose true before it closes.

HTH!

-Brad
 
Thank you very much. Now let's see those bastards 'accidently' shut down my application so they can't do their work! :)
 
The process I use (think I got it from Tek-Tips, but can't remember from whom) is this:

Create a form called frmExit with one check box (chkExit) whose default value is false. This code is in the Unload event:

Private Sub Form_Unload(Cancel As Integer)

If chkExit = False Then
Cancel = -1
End If

End Sub


In the On Open event of my main menu form I open frmExit as follows:

DoCmd.OpenForm "frmExit", , , , , acHidden

This effectively disables the Application close button.

In the Click event for the cmdQuit button on the main menu I change the status of the check box to True:

Forms!frmExit.chkExit = True

Once the chkExit value is true, the database can close normally.

Simple and effective.

Hope this helps. Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Why not just set the min/max buttons to disable (thru the form properties) and set the control box = no , also under the forms properties. Also under tools->startup disable the full menu and anything else you feel you need to disable (AT YOUR OWN RISK). This should prevent users from exiting your app.
 
Pweegar:

That will only disable the form's close buttons. The application close button will still be available.

There is no way I have found to remove the application close button or to disable it short of the solutions provided here. Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Thanks all. I fixed a problem I wasn't trying to fix today. I gave ya'll stars. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top