A
Andy Ellis
I have a report which needs to be programmatically modified at runtime before
running. All my reports are driven by a report selection form (allowing me
to set up custom filtering), and the last code snippet in its OK button code
is as follows...
...
...
DoCmd.SetWarnings False
DoCmd.OpenReport strReportName, acViewDesign
Set oReport = Reports(strReportName)
With oReport
.Controls("lblFilterDescription").Caption = strFilterDescription
.Visible = False
.Section(acFooter).Visible = (nService = 0)
.RecordSource = strRecordSource
End With
DoCmd.Close acReport, strReportName, acSaveYes
Set oReport = Nothing
DoEvents
DoCmd.OpenReport strReportName
DoCmd.Close acForm, "ReportsMenu"
DoCmd.SetWarnings False
(The main purpose of the form is to build strRecordSource and apply it to
the report. I can't use Access filtering here due to the complexities of the
queries behind the reports. lblFilterDescription is a label on the report
header, giving a user-friendly description of the filtering criteria
specified. nService is the selected member of the highest-level grouping
category, and 0 means all members are shown so the report footer is needed to
give report totals.)
For some reports, this works just fine. But for one, Access hangs. If I
single-step through the code, I can see that it never finishes the
DoCmd.Close acReport, strReportName, acSaveYes
Anyone seen this, or something similar to it, before?
running. All my reports are driven by a report selection form (allowing me
to set up custom filtering), and the last code snippet in its OK button code
is as follows...
...
...
DoCmd.SetWarnings False
DoCmd.OpenReport strReportName, acViewDesign
Set oReport = Reports(strReportName)
With oReport
.Controls("lblFilterDescription").Caption = strFilterDescription
.Visible = False
.Section(acFooter).Visible = (nService = 0)
.RecordSource = strRecordSource
End With
DoCmd.Close acReport, strReportName, acSaveYes
Set oReport = Nothing
DoEvents
DoCmd.OpenReport strReportName
DoCmd.Close acForm, "ReportsMenu"
DoCmd.SetWarnings False
(The main purpose of the form is to build strRecordSource and apply it to
the report. I can't use Access filtering here due to the complexities of the
queries behind the reports. lblFilterDescription is a label on the report
header, giving a user-friendly description of the filtering criteria
specified. nService is the selected member of the highest-level grouping
category, and 0 means all members are shown so the report footer is needed to
give report totals.)
For some reports, this works just fine. But for one, Access hangs. If I
single-step through the code, I can see that it never finishes the
DoCmd.Close acReport, strReportName, acSaveYes
Anyone seen this, or something similar to it, before?