Cancel Button Problems

A

ATSBC03

I have created a form to filter my report. The report is based on a query and
the form is an unbound form with combo boxes and text fields to allow data to
be selected. I have been trying to set up the cancel but to cancel the report
and close the form. However, it is not working and when the cancel button is
selected it runs the report with all data.

Private Sub btncancel_Click()
Cancel = True
DoCmd.Close acForm, "frmSiteDept"
End Sub

When I have tried to do a DoCmd.Close acReport, "rptAllComments" I get an
error message stating that I cannot perform that operation while a report or
form is running. I am at a loss as to what to do. Any help would be greatly
appreciated.
 
A

ATSBC03

I want to cancel before the report pops up but it is opening the report
anyway when the cancel button is pressed.
 

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