Report using date range parameters

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.
 
D

Duane Hookom

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
 

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