Hi ,
I assume the report data source is a query , if so the criteria section
needs to have the following
between forms!formname!startdate and forms!formname!enddate
this also need to be added to the parameters section showing the data type
create a form with two textboxs startdata and enddate
Under code header
Option Compare Database
Option Explicit
Public Fopening as Boolean ' add this public variable
then on the report on open event add this code
Private Sub Report_Open(Cancel As Integer)
Dim StrFormName As String
StrFormName = "FormName"
Fopening = True
DoCmd.OpenForm StrFormName, , , , , acDialog
If IsLoaded(StrFormName) = False Then Cancel = True
End Sub
and in the modules section add this routine
Function IsLoaded(ByVal StrFormName As String) As Integer
' Returns True if the specified form is open in Form view or Datasheet
view.
Const conObjStateClosed = 0
Const conDesignView = 0
If SysCmd(acSysCmdGetObjectState, acForm, StrFormName) <>
conObjStateClosed Then
If Forms(StrFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If
End Function
regards
Ian
Quote:
> On Tue, 13 May 2003 15:15:44 -0400, "Gary Nelson"
> >In Access 2000, I have a report that I need to set a date range in.
> >For example, when the user clicks the button on the main menu to open the
> >form, a message box is to pop up asking for a beginning date. Once this
is
> >filled in, the user clicks ok, then another message box pops up asking
for
> >an ending date. Once this is filed in, the user clicks ok, and the
report
> >opens with the data listed in the report from the date range specified.
> >Can someone please tell me what code I need to put into the design view
of
> >the query behind the report?
> On the Criteria line under the date field put:
> >= [Enter beginning date:] AND <= [Enter ending date:]
> Or, better IMO, create a small unbound Form frmCrit with two
> textboxes, txtStartDate and txtEndDate; use criteria of
> >= [Forms]![frmCrit]!txtStartDate AND <= [Forms]![frmCrit]!txtEndDate
> and put a command button on the form to open the Report.
> John W. Vinson[MVP]
> Come for live chats every Tuesday and Thursday
> http://go.compuserve.com/msdevapps?loc=us&access=public