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!

Generate a pdf for each page break on ms access report 1

Status
Not open for further replies.

evr72

MIS
Dec 8, 2009
265
US
Hello,

Not sure if this is possible.

I have a score card report for all my vendors. When I click on export, I can export it as a pdf file, this exports the whole report on one pdf. Is there a way I could export each page break as a pdf so I then can email it to each vendor?

thanks!!
 
This is how I would do it. Modify the code to support your primary ID

I loop through all my employees (vendors) and then filter the form based on my employee. Then save the rpt with the employees name and current date into a specifieid folder. In the reports query I have a where criteria.

WHERE qryOrders.LastName = getLastName() OR getLastName()=""

The where string allows me to open the report and see all records, but filter the records when run through code.

Code:
Public glblLastName As String

Public Sub OutputEmployeeOrders()
  Const strPath = "C:\Orders\"
  Dim strPathAndFile As String
  Dim rs As DAO.Recordset
  Set rs = CurrentDb.OpenRecordset("Employees")
  Do While Not rs.EOF
    glblLastName = rs!lastName
    strPathAndFile = strPath & glblLastName & " " & Format(Date, "DDMMMYYYY") & ".PDF"
    DoCmd.OutputTo acOutputReport, "rptOrders", acFormatPDF, strPathAndFile
    rs.MoveNext
 Loop
 glblLastName = ""
End Sub

Public Function getLastName() As String
  getLastName = glblLastName
End Function
BTW I can use this code to send the report to an email and recipient directly.
 
MajP,
I think I get it, not very good at coding

My table is called vendors, from there I make a report so

I would do something like this:
Code:
Public glblLastName As String

Public Sub OutputEmployeeOrders()
  Const strPath = "C:\Orders\"
  Dim strPathAndFile As String
  Dim rs As DAO.Recordset
  Set rs = CurrentDb.OpenRecordset("vendors")
  Do While Not rs.EOF
    glblLastName = rs!vendnum
    strPathAndFile = strPath & glblLastName & ".PDF"
    DoCmd.OutputTo acOutputReport, "rptOrders", acFormatPDF, strPathAndFile
    rs.MoveNext
 Loop
 glblLastName = ""
End Sub

Public Function getLastName() As String
  getLastName = glblLastName
End Function

Thanks for taking a look at my question!!!
 
Assuming your table of vendors is called "Vendors"
And the "vendNum" is the primary key in your table.
I would modify like


CODE
Public glblVendNum As String

Public Sub OutputVendorScoreCards()
'your path goes here
Const strPath = "C:\VendorScoreCards\"
Dim strPathAndFile As String
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("vendors")
Do While Not rs.EOF
glblVendNum = rs!vendnum
strPathAndFile = strPath & glblVendNum & ".PDF"
DoCmd.OutputTo acOutputReport, "rptYourReportName", acFormatPDF, strPathAndFile
rs.MoveNext
Loop
glblVendNum = ""
End Sub

Public Function getLastName() As String
getVendNum = glblVendNum
End Function

Thanks for taking a look at my question!!!

if the vendNum is numeric then change these lines
Public glblVendNum As Long
glblVendNum = 0

And the report query should be something like
WHERE yourQuery.vendNum = getVendNum() OR getVendNum() = 0
 
Thank you!!! I appreciate the help!!!

sorry for the late reply
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top