Cancel query that runs report from form

G

Guest

Hello,
I am fairly new to access, so I am hoping someone can help.
I have created a report and in the reports On Open event, I have a macro
that opens a form to enter the query criteria for that report.
When I enter the criteria in the form and click the OK command button the
report runs fine. What I need is a cancel button that will stop the query
and report from running, and close the form. I have created a macro to close
the form but once the form closes it still prompts me for the criteria for
the query.
How do I close the form and cancel the query and report?

Thanks,
Angie
 
F

fredg

Hello,
I am fairly new to access, so I am hoping someone can help.
I have created a report and in the reports On Open event, I have a macro
that opens a form to enter the query criteria for that report.
When I enter the criteria in the form and click the OK command button the
report runs fine. What I need is a cancel button that will stop the query
and report from running, and close the form. I have created a macro to close
the form but once the form closes it still prompts me for the criteria for
the query.
How do I close the form and cancel the query and report?

Thanks,
Angie

If you want a special command button to close the parameter form (you
could use the form's close button), add a command button to the form.
Code it's click event:
DoCmd.Close acForm, Me.Name

I'll assume you have Access 2000 or newer.
Don't use the macro.
Code the report's Open event

DoCmd.OpenForm "ParameterFormName", , , , ,acDialog

If Not CurrentProject.AllForms("ParameterFormName").IsLoaded Then
MsgBox "You have cancelled the report."
Cancel = true
End If

If you have Access 97, post back.
 

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