report still looks for parameters when parameter form is cancelled

  • Thread starter Thread starter Sarahb
  • Start date Start date
S

Sarahb

I have a report based on a query that gets its criteria from a form. The
report also uses the same criteria for the header using an unbound text box.
Everything is fine unless I press cancel on the form that collects the
criteria. The form shuts, but a parameter dialog box pops up looking for the
criteria for the header for the report, even though it should have been
cancelled. I am not sure where the code is wrong, is it a problem with the
cancel button on the form, or something on the report? Can anyone help please?
 
Probably a logic error in your "cancel the opening of the report" button
code -- the report apparently. Post the code that you're using.
 
Sarahb said:
I have a report based on a query that gets its criteria from a form. The
report also uses the same criteria for the header using an unbound text box.
Everything is fine unless I press cancel on the form that collects the
criteria. The form shuts, but a parameter dialog box pops up looking for the
criteria for the header for the report, even though it should have been
cancelled. I am not sure where the code is wrong, is it a problem with the
cancel button on the form, or something on the report?

I believe the problem is in the logic flow of the code that
opens the report and the form. If the report opens the
form, then you need to deal with the cancel in the report.
If the form opens the report, then it should be simple for
the cancel to skip opening the report.
 
Thank you for your replies. The report opens the form. The code in the
report I have used is:

Private Sub Report_Open(Cancel As Integer)
bInReportOpenEvent = True

DoCmd.OpenForm "frmdateandmonth", , , , , acDialog

bInReportOpenEvent = False
End Sub

Private Sub Report_Close()
DoCmd.Close acForm, "frmdateandmonth"
End Sub


The cancel code in the form is:

Private Sub cmdCancel_Click()
DoCmd.Close acForm, "frmdateandmonth"
End Sub

Thanks

Sarah
 
Sarahb said:
Thank you for your replies. The report opens the form. The code in the
report I have used is:

Private Sub Report_Open(Cancel As Integer)
bInReportOpenEvent = True

DoCmd.OpenForm "frmdateandmonth", , , , , acDialog

bInReportOpenEvent = False
End Sub

Private Sub Report_Close()
DoCmd.Close acForm, "frmdateandmonth"
End Sub


The cancel code in the form is:

Private Sub cmdCancel_Click()
DoCmd.Close acForm, "frmdateandmonth"
End Sub

And the form's OK button's code is ??? Presuming it's
Me.Visible = False

The all the report has to do is check if the form is still
open:

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "frmdateandmonth", , , , , acDialog
If Not CurrentProject.AllForms!frmdateandmonth.IsLoaded _
Then Cancel = True
End Sub
 
That's great - thanks for your help

Sarah

Marshall Barton said:
And the form's OK button's code is ??? Presuming it's
Me.Visible = False

The all the report has to do is check if the form is still
open:

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "frmdateandmonth", , , , , acDialog
If Not CurrentProject.AllForms!frmdateandmonth.IsLoaded _
Then Cancel = True
End Sub
 
Back
Top