Close form / Error in DSum totals

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
 
J

JeffW

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top