473,415 Members | 1,566 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,415 software developers and data experts.

Run On Close Form Event If DB is Closed

AP
IS there a way to run a procedure if the users close access directly
rather than closing a menu screen that I have built? There is an event
that works on close for this form, but it doesnt seem to run if the
form is open and the suer just closes access all together, is there a
way around this?
Thanks

Nov 23 '05 #1
5 7417
One thing you can do that's a bit of a dirty trick is to run a hidden,
minimized form when your database opens. This form will have the code
you want to run when the dbase closes in its Form_Close event. When the
user closes the database, the hidden form's Form_Close event will
eventually get fired, and your code will run.

Nov 23 '05 #2
On 23 Nov 2005 10:19:00 -0800, "AP" <ap******@thompsongroup.com>
wrote:
IS there a way to run a procedure if the users close access directly
rather than closing a menu screen that I have built? There is an event
that works on close for this form, but it doesnt seem to run if the
form is open and the suer just closes access all together, is there a
way around this?


Something doesn't seem right. You are saying that you have an open
form and that open form has an event procedure in its On Close event
and that if a user selects the 'x' in the upper right hand corner to
close Access that your On Close event procedure doesn't fire?

If so, I fail to see how Steve's idea of adding a hidden form with
"just another" On Close event will help.

mike
Nov 24 '05 #3
Mike Preston wrote:
On 23 Nov 2005 10:19:00 -0800, "AP" <ap******@thompsongroup.com>
wrote:

IS there a way to run a procedure if the users close access directly
rather than closing a menu screen that I have built? There is an event
that works on close for this form, but it doesnt seem to run if the
form is open and the suer just closes access all together, is there a
way around this?

Something doesn't seem right. You are saying that you have an open
form and that open form has an event procedure in its On Close event
and that if a user selects the 'x' in the upper right hand corner to
close Access that your On Close event procedure doesn't fire?

If so, I fail to see how Steve's idea of adding a hidden form with
"just another" On Close event will help.


I believe his thinking is as so:

On startup open the first form as hidden whether this is done with an AutoExec macro or
setting the Startup Form option.

Because it is hidden the user can't close it themselves.

Because it is the first form opened it will be the last form closed.

Use the form's Unload event to run whatever code you need to execute prior to the instance
of Access closing.

--
'---------------
'John Mishefske
'---------------
Nov 24 '05 #4
On Thu, 24 Nov 2005 07:55:35 GMT, John Mishefske
<jm**********@SPAMyahoo.com> wrote:
Mike Preston wrote:
On 23 Nov 2005 10:19:00 -0800, "AP" <ap******@thompsongroup.com>
wrote:

IS there a way to run a procedure if the users close access directly
rather than closing a menu screen that I have built? There is an event
that works on close for this form, but it doesnt seem to run if the
form is open and the suer just closes access all together, is there a
way around this?

Something doesn't seem right. You are saying that you have an open
form and that open form has an event procedure in its On Close event
and that if a user selects the 'x' in the upper right hand corner to
close Access that your On Close event procedure doesn't fire?

If so, I fail to see how Steve's idea of adding a hidden form with
"just another" On Close event will help.


I believe his thinking is as so:

On startup open the first form as hidden whether this is done with an AutoExec macro or
setting the Startup Form option.

Because it is hidden the user can't close it themselves.

Because it is the first form opened it will be the last form closed.

Use the form's Unload event to run whatever code you need to execute prior to the instance
of Access closing.


Well, I certainly agree with your last comment. The unload event is
what I use to preclude exiting. However, that is because I don't want
the form to unload. While the On Close event can't be cancelled, it
most assuredly will run if the user clicks any "X" that will exit
Access. Won't it?

And if the OP's problem is that the OnClose of the open form isn't
firing, I'd be worried about that (corruption?).

mike
Nov 24 '05 #5
Use your Main MenuForm or a hiddenform.

Option Compare Database
Option Explicit
Dim blnDbCanClose As Boolean

Private Sub Form_Unload(Cancel As Integer)
If Not blnDbCanClose Then Cancel = True
End Sub

Private Sub BtnClose_Click()
If MsgBox("Want to quit?", vbInformation + vbOKCancel, "Log out") = vbOK Then
blnDbCanClose = True
DoCmd.Quit
End If
End Sub

If you use your Main MenuForm you will have to set the blnDbCanClose to True to go to design view ...
So if you are using a hidden form I guess it is more convenient.

Arno R

"Mike Preston" <mb******@pacbell.net.invalid> schreef in bericht news:43*****************@news.INDIVIDUAL.NET...
On 23 Nov 2005 10:19:00 -0800, "AP" <ap******@thompsongroup.com>
wrote:
IS there a way to run a procedure if the users close access directly
rather than closing a menu screen that I have built? There is an event
that works on close for this form, but it doesnt seem to run if the
form is open and the suer just closes access all together, is there a
way around this?


Something doesn't seem right. You are saying that you have an open
form and that open form has an event procedure in its On Close event
and that if a user selects the 'x' in the upper right hand corner to
close Access that your On Close event procedure doesn't fire?

If so, I fail to see how Steve's idea of adding a hidden form with
"just another" On Close event will help.

mike

Nov 24 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Irvin Amoraal | last post by:
Process: I have a form which uploads a file from client to server written in PHP. When the user presses the submit button, I use the "onSubmit" event to execute javascript to open a child window...
11
by: Pablo Salazar | last post by:
Hi people!!. Which is diference between to use method CLOSE and DISPOSE to close a form? Tx. Pablo Salazar
2
by: Chien Lau | last post by:
Hi, At a certain point in my application, I have access to a Form object. I want to close that form: form.Close(); There are any number of reasons why this form might not close. A common...
5
by: Stan Sainte-Rose | last post by:
Hi, Which event is called when the user click on the close window icon (X) ? I want, when he clicks on this icon, to display a message before closing the form. If he replys by No, I don't want to...
19
by: Nathan | last post by:
I know this has been asked previously, but I've run into a situation where I need to know the difference between close and dispose, and I can't get the information I need from msdn help or previous...
3
by: rdemyan via AccessMonster.com | last post by:
I need help with code to close two forms at the same time, FormA and FormB. I need code that can be used from either form and needs to work with both a 'Close' button on each form as well as if the...
1
by: dan.c.roth | last post by:
oForm.Close() vs this.Close() in a modal dialog. oFrom.Close() calls Form.Dispose() but this.Close() ,say in the click event of the Form, does not. I can think of the reason for this but is...
2
by: Carla Simeoni | last post by:
Assume I have an open Form. Then I click the "normal" window "X" icon (=Close button). How do I assign a function in Form.cs to this event ? In other words if this Form/window is closed I want to...
5
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.