Results 1 to 2 of 2
Thread: Filtering Reported Data (97;SR2)
2002-10-14, 14:57 #1
- Join Date
- Dec 2000
- California, USA
- Thanked 0 Times in 0 Posts
Filtering Reported Data (97;SR2)
Is it possible to apply a filter on a report? I have a report that utilizes a query (which has data relating to various departments) which I would like the end result to reflect only one department's information. I really don't want to change the query itself as I use it to generate other reports.
2002-10-14, 15:13 #2
- Join Date
- Mar 2002
- Thanked 30 Times in 30 Posts
Re: Filtering Reported Data (97;SR2)
You can apply a filter in code.
In the first place, you might have a form on which the user selects a department, with a command button to open the report. The code in the OnClick event procedure of the command button might look like:
<pre>DoCmd.OpenReport "rptMyReport", acViewPreview, , "[DeptID] = " & Me.[DeptID]</pre>
for a numeric DeptID, or
<pre>DoCmd.OpenReport "rptMyReport", acViewPreview, , "[DeptID] = '" & Me.[DeptID] & "'"</pre>
for a string DeptID. Of course, you must replace the various names in this instruction by the appropriate ones.
It is also possible to set a filter when the report is already opened, by setting the Filter and FilterOn properties of the report. Microsoft has a report samples database that demonstrates this. You can download it from ACC97: Microsoft Access 97 Sample Reports Available in Download Center.