Filtering Between Dates

  • Thread starter Thread starter LA Lawyer
  • Start date Start date
L

LA Lawyer

I want to filter a report between two dates for the purpose of billing a
specific client. I also want the default start date to be January 1 of the
current year.

I have already obtained: StartDate, EndDate, strClientName.

ClientName and MainDate are the relevant fields on the source table for the
report.

Here is my current code for the filter which does not work:

Reports!BillsReport.Filter = "ClientName ='" & strClientName & "' AND " &
MainDate > StartDate & " AND " & MainDate < EndDate
Reports!BillsReport.FilterOn = True

I have similar code for similar reports which work fine so I know that my
filter is bad.
 
Reports!BillsReport.Filter = "ClientName ='" & strClientName & _
"' AND MainDate > " & Format(StartDate, "\#yyyy\-mm\-dd\#") & _
" AND MainDate < " & Format(EndDate, "\#yyyy\-mm\-dd\#")
Reports!BillsReport.FilterOn = True
 
Back
Top