By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,604 Members | 858 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,604 IT Pros & Developers. It's quick & easy.

Closing Access 2000

P: n/a
Is there a way to force the user of a database to exit and close access
through a close button on for example a switchboard menu?

If a user closes access by the exit command or the close button on access,
this will prevent certain housekeeping routines to function unless thay quit
through the database. Another alternative would be to also hook these
functions to the close button on access or the exit command (file menu).

Thank you in advance for any information in accomplishing this.
Nathan Bloom
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
The trick with this is that Access cannot close unless all the forms,
reports etc are closed.

So what you do is have a form which only closes if a form variable is set to
a particular value

A simple example

1) Create a new database
2) Create a form in the database (Form1)

3) Create a command button on the form (Command1)

4) Add the following code to the form module

' *************************************
' Code start
Private blnCanUnload As Boolean

Private Sub Command0_Click()
blnCanUnload = True
MsgBox "Clean Up Code here"
DoCmd.Close acForm, Me.Name, acSavePrompt
DoCmd.Quit acQuitPrompt
End Sub

Private Sub Form_Load()
blnCanUnload = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
Cancel = Not blnCanUnload
If Cancel Then
MsgBox "Click the command button before you can unload Access"
End If
End Sub
' Code end
' *************************************

4) Save the form

Now with the form open
a) click the close button on the access window
(you'll get the message about clicking the command button)
b) click the command button on the form
c) click the close button on the access window
(you get the message about clean up code and access closes)
Terry

"Nathan Bloom" <na*******@earthlink.net> wrote in message
news:0H***************@newsread4.news.pas.earthlin k.net...
Is there a way to force the user of a database to exit and close access
through a close button on for example a switchboard menu?

If a user closes access by the exit command or the close button on access,
this will prevent certain housekeeping routines to function unless thay quit through the database. Another alternative would be to also hook these
functions to the close button on access or the exit command (file menu).

Thank you in advance for any information in accomplishing this.
Nathan Bloom

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.