Report using date range parameters

  • Thread starter Thread starter Don Reinken
  • Start date Start date
D

Don Reinken

How would I code an Access 2000 report so the user can
input a beginning date and an ending date to filter the
record source?

Any help will be greatly appreciated! Thanks.
 
I always use text boxes (or other controls) on forms for users to enter
report/form criteria. I then modify the code in the command button that
opens the report:
Dim strWhere as String
Dim strReport as String
strReport = "rptMySalesReport"
strWhere = "1 = 1 "
If Not IsNull(Me.txtStartDate) Then
strWhere = strWhere & " And SalesDate >= #" & _
Me.txtStartDate & "# "
End If
If Not IsNull(Me.txtEndDate) Then
strWhere = strWhere & " And SalesDate <= #" & _
Me.txtEndDate & "# "
End If
DoCmd.OpenReport strReport, acViewPreview, , strWhere
 
Back
Top