G
Guest
I have a list box in my form (frmReports) that allows users to click on
desired reports for preview and printing. The frmReports form stays on top,
so the user can select another report and preview it as well. The intention
of the code in cmdClose is to close all open reports, and close frmReports as
well. I know the For-Next statement works, when I run it in the immediate
window, it correctly displays the names of all open reports. However, the
code is only closing the first open report, not ALL open reports.
How can I modify this code to close ALL open reports?
Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click
Dim rpt As Report
For Each rpt In Reports
DoCmd.Close acReport, rpt.Name, acSaveNo
Next rpt
DoCmd.Close acForm, "frmReports", acSaveNo
Exit_cmdClose_Click:
Exit Sub
Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click
End Sub
desired reports for preview and printing. The frmReports form stays on top,
so the user can select another report and preview it as well. The intention
of the code in cmdClose is to close all open reports, and close frmReports as
well. I know the For-Next statement works, when I run it in the immediate
window, it correctly displays the names of all open reports. However, the
code is only closing the first open report, not ALL open reports.
How can I modify this code to close ALL open reports?
Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click
Dim rpt As Report
For Each rpt In Reports
DoCmd.Close acReport, rpt.Name, acSaveNo
Next rpt
DoCmd.Close acForm, "frmReports", acSaveNo
Exit_cmdClose_Click:
Exit Sub
Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click
End Sub