Close form / Error in DSum totals

  • Thread starter Thread starter Kevin Bruce
  • Start date Start date
K

Kevin Bruce

An On_Click event is used to open a report
("rptAIEapplicationTotalsByDistrict").

In the SQL statement for the report is a statement that refers to the year
selected on the form ("frmAIEgeneralReports") which limits the data shown on
the report.

Once the report has been opened, the form should close.

There are DSum statements in the footer of the report that work only if the
form is still open or is closed manually. These DSum statements also refer
to the year selected on the form.

If the following code is used to open the report and then close the form,
the DSum statements in the footer of the report show errors.


Private Sub cmdPrevRptAppnTotalsByDistrict_Click()

Dim stDocName As String

stDocName = "rptAIEapplicationTotalsByDistrict"
DoCmd.OpenReport stDocName, acPreview

stDocName = "frmAIEgeneralreports"
DoCmd.Close acForm, stDocName

End Sub


By simply eliminating the "DoCmd.Clse acForm..." line, the report opens
without errors. Even after I close the form manually, the report still reads
perfectly. Why can I not automote the closing of the form without generating
errors on the report?

Thanks in advance for any advice.

_Kevin
 
Hide the form instead of closing it on the Click event by setting its
visible property to false. Then close the form with the Load or Unload event
of your report.

HTH,
Jeff
 
Back
Top