PC Review


Reply
Thread Tools Rate Thread

Closing Access While Form Is In Print Preview Does Not Trigger Form Unload Event

 
 
Stewart Berman
Guest
Posts: n/a
 
      4th Jun 2010
We use the form unload event of our main form to make sure the user exist
through our exit process instead of just closing access with the top right X
on the access application. This works if the form is in form view.

However, if the user uses the Office button to do a Print\Preview and then
clicks on the top right X on the access application access closes without
triggering the form unload event.

Is this by design or a bug? Is there away around this behavior? Is there a
way to prevent a form from going into print preview mode while still
allowing the use of the Office button Print\Preview for reports?

 
Reply With Quote
 
 
 
 
Jeanette Cunningham
Guest
Posts: n/a
 
      5th Jun 2010
I use this sort of thing on the unload event of a form that is always open
and hidden.

Private Sub Form_Unload(Cancel As Integer)
'if user has report open, gives chance to say no
'if they clicked the main app X by mistake
'and runs the quit actions code before access closes

'Debug.Print Reports.Count
If Reports.count > 0 Then
If vbCancel = MsgBox("Are you sure you want to close the
database?", vbOKCancel, Close?) Then
Cancel = True
Else
'code here to call the exit routine
End If
End If
End Sub

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"Stewart Berman" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> We use the form unload event of our main form to make sure the user exist
> through our exit process instead of just closing access with the top right
> X
> on the access application. This works if the form is in form view.
>
> However, if the user uses the Office button to do a Print\Preview and then
> clicks on the top right X on the access application access closes without
> triggering the form unload event.
>
> Is this by design or a bug? Is there away around this behavior? Is there
> a
> way to prevent a form from going into print preview mode while still
> allowing the use of the Office button Print\Preview for reports?
>



 
Reply With Quote
 
Stewart Berman
Guest
Posts: n/a
 
      6th Jun 2010
We original tried that but the main form has to do a good deal of cleanup
before closing and there was no way to stop it from being closed before the
form unload event in the invisible form is invoked. Once application close
is invoked by clicking on the X there is no guarantee as to the order access
will close open objects.

"Jeanette Cunningham" <(E-Mail Removed)> wrote:

>I use this sort of thing on the unload event of a form that is always open
>and hidden.
>
>Private Sub Form_Unload(Cancel As Integer)
>'if user has report open, gives chance to say no
>'if they clicked the main app X by mistake
>'and runs the quit actions code before access closes
>
> 'Debug.Print Reports.Count
> If Reports.count > 0 Then
> If vbCancel = MsgBox("Are you sure you want to close the
>database?", vbOKCancel, Close?) Then
> Cancel = True
> Else
> 'code here to call the exit routine
> End If
> End If
>End Sub
>
>Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
>
>"Stewart Berman" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> We use the form unload event of our main form to make sure the user exist
>> through our exit process instead of just closing access with the top right
>> X
>> on the access application. This works if the form is in form view.
>>
>> However, if the user uses the Office button to do a Print\Preview and then
>> clicks on the top right X on the access application access closes without
>> triggering the form unload event.
>>
>> Is this by design or a bug? Is there away around this behavior? Is there
>> a
>> way to prevent a form from going into print preview mode while still
>> allowing the use of the Office button Print\Preview for reports?
>>

>

 
Reply With Quote
 
Jeanette Cunningham
Guest
Posts: n/a
 
      7th Jun 2010
Yes there is, access closes down forms in order.
The first opened form (of the forms that are still open) is the last one to
be closed.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"Stewart Berman" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> We original tried that but the main form has to do a good deal of cleanup
> before closing and there was no way to stop it from being closed before
> the
> form unload event in the invisible form is invoked. Once application
> close
> is invoked by clicking on the X there is no guarantee as to the order
> access
> will close open objects.
>
> "Jeanette Cunningham" <(E-Mail Removed)> wrote:
>
>>I use this sort of thing on the unload event of a form that is always open
>>and hidden.
>>
>>Private Sub Form_Unload(Cancel As Integer)
>>'if user has report open, gives chance to say no
>>'if they clicked the main app X by mistake
>>'and runs the quit actions code before access closes
>>
>> 'Debug.Print Reports.Count
>> If Reports.count > 0 Then
>> If vbCancel = MsgBox("Are you sure you want to close the
>>database?", vbOKCancel, Close?) Then
>> Cancel = True
>> Else
>> 'code here to call the exit routine
>> End If
>> End If
>>End Sub
>>
>>Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
>>
>>"Stewart Berman" <(E-Mail Removed)> wrote in message
>>news:(E-Mail Removed)...
>>> We use the form unload event of our main form to make sure the user
>>> exist
>>> through our exit process instead of just closing access with the top
>>> right
>>> X
>>> on the access application. This works if the form is in form view.
>>>
>>> However, if the user uses the Office button to do a Print\Preview and
>>> then
>>> clicks on the top right X on the access application access closes
>>> without
>>> triggering the form unload event.
>>>
>>> Is this by design or a bug? Is there away around this behavior? Is
>>> there
>>> a
>>> way to prevent a form from going into print preview mode while still
>>> allowing the use of the Office button Print\Preview for reports?
>>>

>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access--Form View & Print Preview Display =?Utf-8?B?R0VL?= Microsoft Access Forms 0 4th Jun 2007 12:41 AM
Unload event does not trigger =?Utf-8?B?Sm9lIEUu?= Microsoft Dot NET 0 2nd Jun 2006 02:16 AM
Access 2003 Hide Form to trigger a DB On Close event =?Utf-8?B?UGF0by1jaGFu?= Microsoft Access VBA Modules 2 5th Apr 2006 03:21 PM
my Access form will not print preview...something about my SQL =?Utf-8?B?U2hlbGw=?= Microsoft Access Database Table Design 5 9th Feb 2006 05:17 AM
Why is my access form blank when I go to print preview =?Utf-8?B?Y2F0ZQ==?= Microsoft Access Forms 1 9th Aug 2005 01:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:39 PM.