By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,662 Members | 1,790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,662 IT Pros & Developers. It's quick & easy.

Saving Access Reports as PDFs

P: 7
** Edit ** This post was added to an existing thread (How to save an Access report to pdf with filename based on fieldname) in error so it's been moved here.

Hello to all again.

my little access query (see above), thanks to you, meets some great succes by other users. In that way that they would to integrate this to other entities. One of the users asked me if it was possible to modify it a little to obtain next result. So I need you high competencies again :o)

actually: selecting custumer nr from droplist, click on button, filtered report is created and saved as pdf file with given name (based on fieldname)

would like doing : instead of selecting customer nr from droplist just click on button, run report and save every entity, which appears in the report, as pdf file also with given name (based on fieldname.

Is this technically possible???

Once again thanks in advance

KR

Nicolas
Nov 30 '11 #1

✓ answered by TheSmileyCoder

This is where looping through a recordset comes in Handy.
Expand|Select|Wrap|Line Numbers
  1. Dim rsCustomers as Dao.Recordset
  2. Dim strSQL as String
  3. dim strReportName as string
  4.  
  5. strSQL="SELECT SAP,Cust,Hyperion " & _
  6.        "FROM [Hyperion accounts] " & _
  7.        "ORDER BY [SAP];"
  8. '(This may need to have a WHERE clause applied to it)
  9. set rsCustomers=CurrentDB.Openrecordset(strsql,dbopendynaset)
  10. Do while not rsCustomers.EOF 
  11.  strReportName = rsCustomers!Cust & "-" & rsCustomers!Hyperion & ".pdf"
  12.  DoCmd.OutputTo acOutputReport, "Rep Hyperion recon", acFormatPDF, myPath + strReportName, True 
  13.  rsCustomers.MoveNext
  14. Loop
  15.  
  16. 'Cleanup
  17. set rsCustomers=nothing
  18.  
This will print ALL your customers, so you need some way to specify which customers to print, I suppose it could be based on which customers have had orders this month, but I dont really have the details to specify such a where clause.

Share this Question
Share on Google+
5 Replies


100+
P: 759
What mean "every entity, which appears in the report" ?
Automatic save a .pdf file for each customer in your list ?
Dec 1 '11 #2

P: 7
Hello Mihail,

Thansk for replying

First I have to refer to a previous topic: "How to save an Access report to pdf with filename based on fieldname" in which you can find som more details.

But resumed:
I need to send every month an account statement to each of our entities all over the world. Today's actionflow is:
- select customer nr from drop list ( 1 cust nr = 1 entity)
- click button which runs a code (first: filtering all information, from a global excel file, refering to the selected cust nr, Second: save output into pdf file by given it a specific name based on fieldname. (this works actually fine)

Question is:

just one click on a button, this will create an access report file considering all customer nr. Output in pdf file. But, if report shows 10 customer nr; then I need:
- 10 pdf file; one for each customer
- name of each pdf file must be/contain :"custumer nr" and "name"

Hope this will clarify a little more
Have a nice day
Dec 1 '11 #3

TheSmileyCoder
Expert Mod 100+
P: 2,321
This is where looping through a recordset comes in Handy.
Expand|Select|Wrap|Line Numbers
  1. Dim rsCustomers as Dao.Recordset
  2. Dim strSQL as String
  3. dim strReportName as string
  4.  
  5. strSQL="SELECT SAP,Cust,Hyperion " & _
  6.        "FROM [Hyperion accounts] " & _
  7.        "ORDER BY [SAP];"
  8. '(This may need to have a WHERE clause applied to it)
  9. set rsCustomers=CurrentDB.Openrecordset(strsql,dbopendynaset)
  10. Do while not rsCustomers.EOF 
  11.  strReportName = rsCustomers!Cust & "-" & rsCustomers!Hyperion & ".pdf"
  12.  DoCmd.OutputTo acOutputReport, "Rep Hyperion recon", acFormatPDF, myPath + strReportName, True 
  13.  rsCustomers.MoveNext
  14. Loop
  15.  
  16. 'Cleanup
  17. set rsCustomers=nothing
  18.  
This will print ALL your customers, so you need some way to specify which customers to print, I suppose it could be based on which customers have had orders this month, but I dont really have the details to specify such a where clause.
Dec 1 '11 #4

P: 7
Hello to all and sorry for this (very) late reply.
Once again I have received an answer to my problem
And once again it works fine...

thanks a lot for this great Forum
Dec 6 '11 #5

TheSmileyCoder
Expert Mod 100+
P: 2,321
Better late then never!

Good to see it worked for you.
Dec 6 '11 #6

Post your reply

Sign in to post your reply or Sign up for a free account.