Tom,
first the easy part: showing the date range of the filter on the report:
Put a text box in the header of the report.
Control Source of the textbox:
Code:
="FROM: " & Format([Forms]![frmFilterCostcoData]![cboStartDate],"yyyy-mmm-dd") & " TO: " & Format([Forms]![frmFilterCostcoData]![cboEndDate],"yyyy-mmm-dd")
When the report runs, it will grab the values you pass from the frmFilterCostcoData form controls and the report will only contain the records that fall between the two dates, cboStartDate and cboEndDate.
Filtering the report...
Instead of a hardcoded filter in the query that "gathers" the data for your report, you pass that same WHERE clause (minus the WHERE keyword) in the Open event of the report.
Both queries and reports have filters (basically a WHERE clause, except in a report, you leave off the "WHERE" keyword). So for filters you *always* want applied to the report, you usually put those in the WHERE clause of the query you base the report on. If you want to apply additional filters to the report when you open the report, you can also pass a filter to the report, which filters the report data source a second time (the first is in the query's WHERE clause).
The most flexible way to use a report is to leave the filtering out of the report's data source (the query the report is based on) and then pass a filter in the report's open event in VBA, like this:
Code:
Private Sub Command5_Click() Dim strWhere As String
strWhere = "[InvoiceDate] >= #" & Me.cboStartDate & "# AND [InvoiceDate] <= #" & Me.cboEndDate & "#"
DoCmd.OpenReport "dbo_CostcoData", acViewReport, , strWhere, acWindowNormal
End Sub
I could add other filters, but basically what's happening is that the report is evaluating the contents of the two comboboxes cboStartDate and cboEndDate and passing that filter to the report when it opens (that's what "strWhere" is doing in the OpenReport command).
You don't have to use just one or the other. If you always want the report to have a given static filter, you could include that in the WHERE clause of the query the report is based on, and then add more filters in the code, and the two sets of filters are just basically ANDed together.
Hope that answers your question.