Procedure for "Cancel" button on a form

M

Mike

I have a report which opens a form for entering condition
to the underlying query.
The form has 2 buttons: "OK" and "Cancel"
"OK" button sets the visible property of the form
to "False".
"Cancel" button closes the form.
But when I press "Cancel" I get a message box asking to
enter value for the query to retrieve data. How is it
possible to prevent the message box to appear after
pressing "Cancel"?
 
S

Sandra Daigle

Hi Mike,

When the user presses cancel do you want the report canceled? If so, you
need to build logic into the report that cancels the report when this
condition occurs. If you open the form via the open event of the report, you
can check to see if the dialog form is still open and if not, then set the
cancel parameter to true, which cancels the report.

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "frmRptDialog", , , , , acDialog
If Not IsLoaded("ffrmRptDialog") Then
Cancel = True
End If
End Sub
 
M

Mike

Thank you, Sandra!

-----Original Message-----
Hi Mike,

When the user presses cancel do you want the report canceled? If so, you
need to build logic into the report that cancels the report when this
condition occurs. If you open the form via the open event of the report, you
can check to see if the dialog form is still open and if not, then set the
cancel parameter to true, which cancels the report.

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "frmRptDialog", , , , , acDialog
If Not IsLoaded("ffrmRptDialog") Then
Cancel = True
End If
End Sub

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

I have a report which opens a form for entering condition
to the underlying query.
The form has 2 buttons: "OK" and "Cancel"
"OK" button sets the visible property of the form
to "False".
"Cancel" button closes the form.
But when I press "Cancel" I get a message box asking to
enter value for the query to retrieve data. How is it
possible to prevent the message box to appear after
pressing "Cancel"?

.
 

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