Output one file per record with original formatting

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to out put each record from a report to a seperate file
;otherwords each page gets written to a file with key field as the file name.
Iknow you can output a report using html format and that each page will be
written to its own html file but I lose the formatting of the Access report
and cannot put the key as the filename
Is there a way to output each record to its own unique file while keepimg
the format of the Access report and putting they unique field as the file
name???
 
Akira:

Below is some sample code that outputs each report record to a separate
file. The procedure uses the WHERE parameter of the OpenReport method to
display individual key records. The code assumes the Key value is numeric.
Obviously, you will have to adjust this to your needs. I tried using the
acHidden parameter in the OpenReport method to reduce the screen flashing,
but Access did not like this. I have used RTF format for this example,
however, you can choose another format, depending on your needs.

Function PrintReports()
Dim rs As DAO.Recordset

Set rs = CurrentDb.OpenRecordset("SELECT Key FROM MyTable;")

Do Until rs.EOF
DoCmd.OpenReport "MyReport", acViewPreview, , "Key=" & rs("Key")
DoCmd.OutputTo acOutputReport, "", acFormatRTF, "C:\MyReport_" &
rs("Key") & ".rtf", False
DoCmd.Close acReport, "MyReport", acSaveNo
rs.MoveNext
Loop

Set rs = Nothing

End Function

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.





I need to out put each record from a report to a seperate file
;otherwords each page gets written to a file with key field as the file
name.
Iknow you can output a report using html format and that each page will be
written to its own html file but I lose the formatting of the Access report
and cannot put the key as the filename
Is there a way to output each record to its own unique file while keepimg
the format of the Access report and putting they unique field as the file
name???
 
Back
Top