Option Compare Database
Public WithEvents rpt As Access.Report
Private Sub cmdOpen_Click()
Const rptName = "rptCustomers"
'If you open the report in dialog you will have to add a workaround
DoCmd.OpenReport rptName, acViewPreview
Set rpt = Reports(rptName)
'the below line of code is needed if you do not manually put [Event Procedure]
'in the reports OnClose event property. Easier to add it manually.
rpt.OnClose = "[Event Procedure]"
End Sub
Private Sub rpt_Close()
MsgBox "The Report " & rpt.Name & " is now closed."
End Sub