Procedure for "Cancel" button on a form

  • Thread starter Thread starter Mike
  • Start date Start date
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"?
 
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
 
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"?

.
 
Back
Top