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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running report_close() function

Status
Not open for further replies.

striker73

MIS
Jun 7, 2001
376
US
I have a form with a buttom that opens a report. When the report opens, the report_close() function runs for no reason. I've included some of my code. Any ideas what's going on?

FORM:

If (IsReportLoaded(rptMyReport)=True) Then
DoCmd.Close acReport, rptMyReport
Forms!frmMyForm.SetFocus
DoCmd.Minimize
DoCmd.OpenReport rptMyReport, acViewPreview
Reports!rptMyReport.Filter = condition
Else
DoCmd.Minimize
DoCmd.OpenReport rptMyReport, acViewPreview
Reports!rptMyReport.Filter=condition
End If



REPORT:

Private Sub Report_Close()
MsgBox ("Test")
If (IsFormLoaded(frmMyForm)) Then
Forms!frmMyForm.SetFocus
DoCmd.Restore
Forms!frmMyForm!txtTextField.SetFocus
End If
End Sub



When the report is open in the background, the message box "Test" appears twice.
 
I think I figured out what was going on... I was trying to apply a filter to the report by using the OpenReport WhereConditionm but that wasn't working. I tried a work-around that said Reports!myReport.Filter = MyFilter.

In essence, my report was being opened with all of the data displayed, then closed and re-opened with the filer applied. Because the report was closing in the middle, it was running my report_close() function.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top