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!

Split output to mutiple files?

Status
Not open for further replies.

proximity

Technical User
Sep 19, 2002
132
GB
Hi,

I have a report that prints orders for suppliers. So, for any given date, page one will be all orders for one supplier, page two orders for another and page 3 orders for someone else. And so on.

What I want to do is save each of these pages as separate rtf files (one page per supplier, supplier being the primary key).

Any ideas on the best way to approach this? At the moment, a form allows the user to input a date range. This will then show all the orders for all suppliers for this range. They then save that report as one long RTF file. They then open that in Word and manually save each page as a separate file.

Many thanks for any help received.
 
If you don't need a fully automated method (as I would need to search for some code) you could add a further filter on the form by adding a drop down box? Then after the date range filter is done, the drop down box would pull up the data based on the suppliers within the date range. The user would click in the drop down box and choose a supplier and then your report would print only for that supplier. You could have it printed directly to rtf and use the supplier or some other name to have MS-Access generate the filename for the rtf file.

And example of this would be to add a statement similar to this on the click event of button used to print the report:

Code:
DoCmd.OutputTo acReport, "ReportName", , "C:\TEMP\" & Me.cboSupplier & ".rtf"

"ReportName" would be the name of the report in MS-Access
You would also change the name of the file location and cboSupplier to the name of the dropdown box you create to show the supplier names.
 
Hi,

Thanks for your suggestion sxschech.

I have already tried this technique and it works. However, I guess I do want an automated solution so the user doesn't have to select the supplier then save each file.

However, it is better they do this than split one large file up!
 
To do an automated solution, then you would probably need to set up a loop. Here is a rough outline, for actual code, I'll need to go through some files to find something suitable, so not sure if could get back to you today on that.

You would create a recordset and that would then need to loop one by one (record by record) and pass the value of the supplier name to the report.

I'll see if I can find something soon and post.
 
Did a search in tek-tips and this might help give you and idea. That thread's example was using region, so you would substitute supplier for region and change outputreport to the output command you are using for generating rtf. Also, I would recommend adding these two lines
Code:
rs.movelast
rs.movefirst

between the "Select...
and the "While NOT..."

Code:
'Requires Reference to DAO Library...
'Tools Menu, References "Microsoft DAO"... Should be checked

Dim Db as DAO.Database
Dim RS as DAO.Recordset

Set Db = Currentdb
Set RS = Db.openrecordset "Select Distinct Region From Table"

While NOT(RS.EOF)
    Docmd.openReport "Report Name", acViewNormal,,"Region = """ & RS!Region & """"
    RS.movenext
Wend

You could continue the search in tek-tips. I used "recordset loop"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top