<pi********@hotmail.comwrote in message
news:11**********************@t46g2000cwa.googlegr oups.com...
>
Sounds like there's something here you're not telling. Did you base
your report on a parameter query? Don't. Pass filters in the Open
event of your report. Then if you cancel, nothing should happen. Your
button should have maybe one event
Yes, the form/report is based on those used in many of MS templates. When
the user opens a report the onopen event opens a form frmDateRange where the
user inputs a beginning and ending date, clicks ok and then the report opens
and uses the two values from the date range form in the reports query to
limit the data displayed. What I am looking for is a way for the user to
cancel the date range form and have that form close and essentially the
report close (since I believe it is technically open already since the
calling of frmDateRange is in the reports onopen event).
>
DoCmd.OpenReport "ReportName",.... <somewhere out here is the filter -
just a valid WHERE clause without the WHERE keyword>.
If you don't try to open the report, then you won't get any errors,
just no open report. So I guess it might help if you posted your code.
Report's OnOpen event:
Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "frmReportDateRange", , , , , acDialog
End Sub
Form frmDateRange onClick event for OK Button:
Private Sub cmdOK_Click()
If IsNull([BeginDate]) Or IsNull([EndDate]) Then
MsgBox "You must enter both beginning and ending dates."
DoCmd.GoToControl "BeginDate"
Else
If [BeginDate] [EndDate] Then
MsgBox "Ending date must be greater than Beginning date."
DoCmd.GoToControl "BeginDate"
Else
Me.Visible = False
End If
End If
End Sub
After clicking the OK button, the date range form becomes not visible and
the report becomes visible.
>
Pieter