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

Is it possible to disable the control box of the Access App Window 2

Status
Not open for further replies.

qmacg

Technical User
Aug 20, 2001
47
US
Is it possible to disable the control box of the Access Application Window? I would like to force users to press the Exit button on the Main Menu to Exit the Database instead of closing out Access altogether. I have some code running when the Main Menu is closing, but it gets bypassed when someone just clicks on the Close Button of the Access Window. The Forms object has Control Box and Close Box properties that can be altered, just wondering if the Access Application's window would have similar properties. Any help would be appreciated.
 
Code:
Dim blnClose As Boolean

Private Sub Command0_Click()
  blnClose = True
  DoCmd.Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
  If Not blnClose Then
    DoCmd.CancelEvent
  End If
End Sub
 
Thanks Major P!! I put the first procedure's code on my exit button of the main menu and as you instructed put the other code in the form Unload of the Main Menu. Comical how I kept trying to go into other menus and clicked on the Access Close button, but it would not close the App until I pressed my Exit button on the Main Menu.
One other note though I should include in my results. I put the following code in my Main Menu's OnClose event...:
(This will ensure the database will close down with access).
Thanks Again!

Private Sub Form_Close()

Application.Quit

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top