Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect print preview report closed by user

Status
Not open for further replies.

PeDa

Technical User
Oct 10, 2002
227
NL
Is it possible (Access 2010) for a form that opens a report in Print Preview mode, to detect that the user has subsequently closed that report?
 
Code:
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
 
Code:
Private Sub cmdOpenDialog_Click()
  'If you plan to open dialog then you will have less flexibility or need a bigger workaround than this
  'Set the PopUp property to yes in the report at design time
  'You will have to set the OnClose property to [Event Procedure] as design time
  'You have to open the report by the format Report_YourReportName
  Set rpt = New Report_rptCustomers
  rpt.Visible = True
End Sub

Rest of the process is the same.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top