Form Keeps Reappearing in Report

W

Whitney

I'm using a form to set date ranges and agent names. Once the info is
selected and I hit OK, it reappears again and again. I continue to click ok
until the report appears, but then when scrolling from page to page the form
again appears. I have to click ok to scroll to the next page. Why is this
happening, how can I correct it?
 
D

Duane Hookom

This is happening because something is set up wrong. Are you using subreports
with code that open the form? When you "hit OK" are you closing the form?
 
W

Whitney

Yes to both questions. I have a report for phone stats with a subreport for
email stats. I'm using that same subreport as a regular report as well. So I
need it to open with a form as well. Is that possible to do?
When I click Ok the form does close and then reappears.
 
W

Whitney

I'm assuming that's done in the Event Procedure. What code do I use to keep
it open, but hide it.

This is the current code:
Private Sub Report_Open(Cancel As Integer)
' Set public variable to true to indicate that the report
' is in the Open event


' Open Sales By Category Dialog
DoCmd.OpenForm "ReportDateSelector", , , , , acDialog



' Set public variable to false to indicate that the
' Open event is completed

End Sub
 
D

Duane Hookom

You didn't provide any code that closes the form so I can't help you.
I expect there is some code in the form that closes it.
 
W

Whitney

It looks like it is already making it non-visible.

Private Sub Cancel_Click()
DoCmd.Close acReport, "Daily Flash Report"
DoCmd.Close acForm, "DailyReportDateSelector"
End Sub

Private Sub Form_Open(Cancel As Integer)
Form_Open_Exit:
Exit Sub
End Sub

Private Sub OK_Click()
Me.Visible = False
End Sub

Private Sub ReportDate_Enter()
Me.DTPicker = Date - 1
End Sub
 
D

Duane Hookom

This code looks like one of the reasons why I never use a solution that has
code in the report that opens the filtering form. I always open the form
first and then the report.
 

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