CancelEvent

lorraine

Registered User.
Local time
Today, 14:19
Joined
Jul 25, 2000
Messages
27
I have the following code in a report.

Private Sub Report_Close()
Dim Msg, Style, Title, Response
Msg = "Did you want to save this document to word?"
Style = vbYesNo + vbExclamation
Title = "Save to Word?"

Response = MsgBox(Msg, Style, Title)

If Response = vbYes Then
DoCmd.CancelEvent
Else
Exit Sub


End If

End Sub

What I want to happen is if the user selects 'Yes' then the close event is cancelled, however this is not happening!!

Any assistance would be greatly appreciated

lorraine
 
You should try this in the unload event on the form, which occurs before the clçose event. Unload can be cancelled, close cannot.
 
Thanks for the reply

However, it is a report I am closing and there doesnt appear to be an unload event. Does anybody have any ideas how I can ask the user if they have saved the report to word before they exit

thanks in advance
Lorraine
 
Sorry for misreading Lorraine,

The Deactivate event should make it, like the Unload event on a form. The only difference it that the Deactivate event is fired not only when you close the report but also when the user switches from it to, let s say, a form, table etc.

If necessary deny him this possibility (make everything you want to keep open but the form invisible when the report is opened(open event), then visible again when the report is closed (close event).

Hope this helps.
 
Read:

If necessary deny him this possibility: when the Report is opened (open event) make everything else invisible, then visible again when the report is closed (close event).
 

Users who are viewing this thread

Back
Top Bottom