Alpha Video Training
Results 1 to 5 of 5

Thread: Save Report as individual PDF files using a loop?

  1. #1
    Member
    Real Name
    Lorenzo Verde
    Join Date
    Mar 2009
    Posts
    6

    Default Save Report as individual PDF files using a loop?

    Hello, I have what seems like a simple scenario for someone who knows how to code but is impossible for me to figure out. :) Thank you in advance for your help!!!

    Here's my scenario:
    I have a report that creates "Notifications" for numerous customers. The PDF may be 40 pages long for 35 different customers and I have to open the PDF and break out (save individual PDF) for each customer, ending up with 35 PDF files from the 1 PDF report created by Alpha.

    Question: Can I create a print loop that saves the 35 reports as individual PDFs with the file names being something like "Notification-CustomerABC.pdf" where "CustomerABC" is pulled from a field within the table?

    Here are some more details: the table is named "EFT", the Report is named "Notification" and the customers who need notifications have a value of more than 0 in a field ("Current Balance") located in "EFT" table.

    What other questions do you have in order to provide me with the answer to end my manual PDF creating nightmare!?

  2. #2
    Member Corelius's Avatar
    Real Name
    Cornelius Koempel
    Join Date
    May 2005
    Location
    Germany, Duisburg
    Posts
    175

    Default Re: Save Report as individual PDF files using a loop?

    Hi,
    I would create a report which is filtered by customers id. You can call the report for each customer where customers balance is > 0.

    Code:
    dim tbl as p
    dim qry as p
    tbl = table.open("customers")
    qry = tbl.query_create("","Current_balance > 0")
    
    if qry.records_get() = 1 then
    	while .not. tbl.fetch_eof()
    		:report.SaveAs("Reportname","PDF","costumer->id = " + tbl.id,"","OutputPDF",.f.)
    		tbl.fetch_next()
    	end while
    end if
    tbl.close()
    delete tbl
    delete qry
    This Code is just copy and past, please adapt to your Needs

    Cornelius

  3. #3
    Member
    Real Name
    Lorenzo Verde
    Join Date
    Mar 2009
    Posts
    6

    Default Re: Save Report as individual PDF files using a loop?

    Thank you for the reply Cornelius! I'm working through adapting it for my needs and have a question about " + tbl.id," part. Do I leave it as that or what do I put in its place?

  4. #4
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,683

    Default Re: Save Report as individual PDF files using a loop?

    tbl.id is pointing to the matching field in the customers table as in: Tbl.Customer_id or whatever the field is named in that table that matches the field in the report.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  5. #5
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,387

    Default Re: Save Report as individual PDF files using a loop?

    I do this on a regular basis with employee paysheets and customer invoices.
    I had it setup a long time ago using dbfs, but have switched to sql.
    In my situation, I have to build the pdfs along the way (combine an unknown number of pages into one pdf)
    for each employee/customer.
    I'm willing to share if this seems to be something you require.

Similar Threads

  1. Print / export multiple letters to individual files?
    By smrogers in forum Alpha Five Version 10 - Desktop Applications
    Replies: 1
    Last Post: 02-11-2010, 05:11 PM
  2. report save as rtf cannot save or view
    By panjabi in forum Alpha Five Version 9 - Desktop Applications
    Replies: 15
    Last Post: 09-15-2009, 12:08 PM
  3. Is it possible to filter individual records in a report?
    By Rich Hartnett in forum Alpha Five Version 7
    Replies: 5
    Last Post: 04-01-2006, 05:29 PM
  4. Save letters to Individual files when being produced.
    By OOsorio in forum Alpha Five Version 6
    Replies: 2
    Last Post: 11-21-2005, 03:13 AM
  5. Showing individual tax rates on report
    By Greg Fong in forum Alpha Five Version 4
    Replies: 1
    Last Post: 08-19-2001, 05:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •