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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop Through Reports in Database and Save Them

Status
Not open for further replies.

EliseFreedman

Programmer
Dec 6, 2002
470
GB
Hi

I am using the following code to loop through a series of reports in my database(The Report Names are stored in a table).

Dim db As Database
Dim rs As Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("Reports")
rs.MoveFirst
Do Until rs.EOF
If rs![Print] = True Then DoCmd.OpenReport (rs![ReportName]), A_PREVIEW
rs.MoveNext
Loop
rs.Close

I would now like to add a line of code to automate the saving of the report to a file. The filename would be based on the Report Name for example, One of my reports is called "CreditsAnalysisByCustomer". I want this report to be saved to a file with the filename C:\credits\CreditsAnalysisByCustomer.snp.

Does anyone know how I would set about doing this
 
If saving as a PDF fiel is an option, take a look at my faq703-2533 If you can't use pfg, it may at least point you in the right direction. And as always, please feel free to ask any questions. Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCSA, CNA, MCP, Network+, A+
w: robert.l.johnson.iii@citigroup.com
h: mstrmage@tampabay.rr.com
 
Saving the report with out some additional information in the file name may be (or become) an issue. Without some 'version' identifier, you would be replacing the snapshot on each 'iteration', so any / all previous reports would be lost. Of course, if you do add some versioning info, you then face the opposite question of growth (or bloat) of storage requirements and need to then include a strategy for limiting the number of versions retained.


MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top