Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add filter to report before runtime 2

Status
Not open for further replies.

humbleprogrammer

Programmer
Oct 30, 2002
315
US
Hello,

I have a report that is scheduled to run an outputs to a snapshot format. This report needs to run multiple times with different criteria. I would like to add a filter to it if possible so I don't have to create a different report for each criteria. Again, this is a scheduled report so I can't use a form to apply criteria. My current code works like below:

Code:
DoCmd.OutputTo acReport,"rptOfficeCounts", "SnapshotFormat(*.snp)", "\\servername\reports\SouthOffice\ordercounts.snp", False, ""

I would like to specify a filter for the different offices so I can run the same report for 5 different office.

Any help is greatly appreciated.

Thanks!

 
How are you scheduling that the reports be run. Windows Scheduler?

You could execute an AutoExec of a seperate database that performs a RunCode command. The code to be run could be a subroutine of a database module. In the module have 5 lines of code like you specify above with each having a different filter identifying the particular office that you want to run.

The AutoExec macro would run upon opening the database, execute the printing of the 5 reports, and then perform a application.quit command. This would all be run without a form being opened.

Is this what you were looking for?

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
Hello,

What you described above is exactly how I am already scheduling the reports to run. I have a module with all my scheduled reports and created a macro that calls that module. I them scheduled the macro to run nightly. I am just not sure how to apply the filter in the DoCmd.OutputTo code. Can you help with this?

 
Hi!

The outputto method does not support filtering of the report. What I use, is putting the criterion in the query the report is based on.

For instance, use a public variable, where you change the criterion per each run (a loop?), and use a public function to place this in the criteria row of the query.

Roy-Vidar
 
Roy-Vidar is correct about the OutputTo command and the filter parameter. I overlooked that one. The technique he described is a sound one using the global variable and the Function call in the criteria of the target column in your query will give you the capability to run the five different reports. I do believe that if you are using a table for your record source you could also use the same technique in the Reports Filter property. Just load up the Global variable with the correct filter string and put a call to the function in the Reports Filter property. Make sure the FilterOn property is set to Yes and the report should filter according to the critieia string.

Good luck.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top