New file for each report printed

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

Guest

Hi everybody,

When I print out the report, how I can separate each record on one page??

For example: I have a database that generates a report for each employee
with a detail information about his customers, when I want to print out
reports on my desktop it is printed as one file instead of separate files for
each employee. How I can generate separate report for each employee???

Thanks very much
 
How are you opening the report? You can use VBA to loop through the criteria
and run the report individually for each employee, similar to the following:


Dim rs as new ADODB.Recordset
Dim cnx as ADODB.Connection
Dim strSQL as String
Dim strEmp as String

Set cnx = CurrentProject.Connection
strSQL = "SELECT * From YourTable"
rs.Open strSQL,cnx, adOpenKeyset, adLockOptimistic, adCmdText

If rs.RecordCount > 0 Then
rs.MoveFirst
Do While Not rs.EOF
strEmp = rs.Fields("EmployeeName").Value
DoCmd.OpenReport "YourEmployeeReport", acViewPreview, ,
"EmployeeName = '" & strEmp & "'"
rs.MoveNext
Loop
End If

rs.Close
Set rs = Nothing

If you want to sent the reports directly to the printer, change
acViewPreview to acViewNormal.
If you prefer to save the reports to a file, change the DoCmd.OpenReport
line to:

Snapshot format:
DoCmd.OutputTo acReport, "YourEmployeeReport", "SnapshotFormat(*.snp)",
"C:\YourFolder\YourReport.snp", True

Word format(RichText file):
DoCmd.OutputTo acReport, "YourEmployeeReport", acFormatRTF,
"C:\YourFolder\YourReport.doc", True

Note that rich text docs will not contain images, and checkboxes will not
appear, as rtf doesn't support graphics.
 
First of all, thanks very much for your reply,

The solution was great, but still I have only one question: Could I extract
it as a PDF format?
 
Your care about my problem is highly appreciated by me. I would like to thank
you very much for your help :)
 
Hi again, still I have one problem for this issue. The problem is that for
every record (I mean for every employee) a dialogue will appear again for me
and it will ask about where I want to save my report and what the name for my
file is. I do not want it to appear. Instead, I want to click one bottom and
reports will be saved automatically with ID for the employee??
 
Susan, Can something similar be done for a query based report that is grouped
by location? I have a report that the location header is grouped and forces a
new page "before section". I would like to be able to print this big report
into separate pdf files based on the location header. I do have pdf printer
capability. I appreciate any assistance you can offer. Right now I'm stumped
on how to get this done in a less time consuming manner.

~Rhonda
 
I can tell you how I did this. It ain't pretty but it works. I built my
report on a query that gets a parameter from a screen. I loop through my
parameters placing them on the screen and then exporting them to PDF.
Southern engineering at it's finest but it works.
 
Back
Top