473,657 Members | 2,572 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7434
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******@thomp songroup.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******@thomp songroup.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**********@S PAMyahoo.com> wrote:
Mike Preston wrote:
On 23 Nov 2005 10:19:00 -0800, "AP" <ap******@thomp songroup.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(Can cel 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******@pacbe ll.net.invalid> schreef in bericht news:43******** *********@news. INDIVIDUAL.NET. ..
On 23 Nov 2005 10:19:00 -0800, "AP" <ap******@thomp songroup.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
18703
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 containing some text and an animated GIF. The javascript returns 'True' and the file is uploaded. All of that works great. Problem: Now I am trying to close the child window after the file has been uploaded. Below is the JavaScript I'm using:
11
4281
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
4988
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 reason might be that the user answered "No" when the form's OnClosing() override asked him "Are you sure you want to close this form?"
5
11066
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 close the form. Thks for your help Stan
19
3869
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 posts. I have a game form that has a timer, which runs as long as the game is being played. When the timer reaches zero, the GameOver form is called. On the game form is a Quit button, in whose click event I have only the command "Me.Close"....
3
4418
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 user clicks the 'X' in the control box. I have a function, IsObjectOpen, that can be used to check if a form is open. The function is used as follows: X = IsObjectOpen(FormName,2)
1
3863
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 this documented and if so can someone give me the reference. And is this true for .net 1 and 2. Thanks
2
2311
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 perform some exit statements. When I doubleclick on a "normal" button I am autoamtically taken from the designer pane into the source code editor pane and a new function is automatically inserted. This is not the case for a system button like...
5
5879
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 the screen. I have been unable to find any way to disable this button in Access 2007 and subsequently I have been forced to find ways to detect and handle the situations after the Access Close button has been clicked. I have been largely...
0
8326
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8845
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8622
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5647
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2745
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.