From: Stewart Berman on
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?

From: Jeanette Cunningham on
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" <saberman(a)nospam.nospam> wrote in message
news:1kvi0655kbngmk6jdqoo0i88l00vpvjooh(a)4ax.com...
> 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?
>


From: Stewart Berman on
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" <nnn(a)discussions.microsoft.com> 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" <saberman(a)nospam.nospam> wrote in message
>news:1kvi0655kbngmk6jdqoo0i88l00vpvjooh(a)4ax.com...
>> 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?
>>
>
From: Jeanette Cunningham on
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" <saberman(a)nospam.nospam> wrote in message
news:sk9o061oe3dm665mfrqjvtgfcbo4k299sh(a)4ax.com...
> 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" <nnn(a)discussions.microsoft.com> 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" <saberman(a)nospam.nospam> wrote in message
>>news:1kvi0655kbngmk6jdqoo0i88l00vpvjooh(a)4ax.com...
>>> 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?
>>>
>>