473,326 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Closing Access 2000

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
1 3798
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: MAB71 | last post by:
There should be a way to copy an access database ( .mdb file ) without closing connections to it. Unfortunately the FileCopy statement in VB gives an error if users are connected to the db. But I...
2
by: EH Eisenberger | last post by:
It seems a bug in access. When you open any form in MS Access XP and move to another record from where the form started, and then close the Access application, the FormLoad event will be executed...
1
by: Bill Engel | last post by:
I have a Microsoft Access 2000 database that resides on our server. We have five users who gain access to this database through a network drive. This has worked fine for years…until yesterday. ...
2
by: Rick Caborn | last post by:
I am having a problem with an Access 2000 report getting data from SQL Server 2000. Here are the specifications for it: RecordSource: a stored procedure (tested via query analyzer and working...
5
by: nick_faye | last post by:
Hi, I am still a newbie to VB and using MS Access 2000. I am currently trying to provide a preview of reports before printing them. My program is simple: AC.DoCmd.OpenReport "MyReport",...
6
by: Malcolm Webb | last post by:
I have experimented with the routine to prevent access from closing using the module authored by Dev Ashish to be found at "The Access web" site. Whilst this seems to work, it is not exactly what...
5
by: rdemyan via AccessMonster.com | last post by:
I'm getting the following error message both when opening and closing my dB. The Microsoft Jet database engine cannot find the input table or query 'MSysAccessStorage'. Make sure it exists and...
11
by: Simon van Beek | last post by:
Dear reader, By opening an application I get always the main Access window with the closing cross in the above right corner. Is there a possibility to make this closing cross invisible? ...
4
Fr33dan
by: Fr33dan | last post by:
Hi, I'm having trouble with a multi-threaded program crashing on a specific machine when the worker thread is not initialized at when the _FormClosing method of my main form called. Here is my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.