• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 574
  • Last Modified:

Create a PDF from a report without prompts - Access 2003

I am trying to create a PDF from an Access report, but it is part of a loop, so I do not want the PDF writer to open and nor do I want to be prompted for a file name. The loop runs a report, with a counter, so the file it creates will be for example, "Invoice 1.pdf", then "Invoice2.pdf, etc. I have seen various solutions here, but they seem to not do quite what I want.
0
rick_danger
Asked:
rick_danger
  • 9
  • 8
  • 8
  • +1
1 Solution
 
mbizupCommented:
Something like this?

Dim i as integer
For i = 1 to 5
          DoCmd.OutputTo acOutputReport, "YourReportName", acFormatPDF, "Invoice" & i & ".pdf", False
next

Open in new window

0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
acFormatPDF only started in A2007 or A2010 I think.

I know how to do this ... because I had to do it at work. I will post later tonight. In fact, I have a PDF (no pun) with the exact instructions on how to set this up - step by step - at work - and can post that tomorrow.
0
 
mbizupCommented:
Right you are.  I overlooked the A2K3 part.
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Jeffrey CoachmanMIS LiasonCommented:
rick_danger,

I use the Lebans code to convert to PDF in Access 2003.
http://www.lebans.com/reporttopdf.htm

Attached is a sample I made a while ago.
(It loops the customers instead of using a counter)
judging form your post, you seem like you can see what I did here and adapt it to your application.

JeffCoachman
Access-BulkConvertIndividualCust.mdb
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Just an FYI ... not positive, but should you  happen to upgrade to >=A2007, I think the Leban's PDF has some issues. But for A2003, the Leban's code certainly does work ... and I have used it.

Also ... I just realized that my approach - which was my only option for running MDBs in A2010 environment ... and involves creating a 2nd virtual PDF Printer on your system (not hard to do) ... will require the same thing on any system that needs to run your db. In my case, I had to set up about a dozen peeps systems. Again, my only option.

mx
0
 
rick_dangerAuthor Commented:
Boag2000
I have tried this on my PC, which Access 2010, but it doesn't work. Is this the problem that you mentioned? I will be trying it out on the A2003 machine later. The solution looks really good, and I appreciate the way you have included the loop too.

I'll let you know how I get on.
0
 
Jeffrey CoachmanMIS LiasonCommented:
<but it doesn't work>
Please clearly define "doesn't work"

<Is this the problem that you mentioned?>
I never mentioned a "problem" per se, ...I only stated that instead of a counter, I was looping the Customer table.

If you read the info in the Lebans.com link, and read my notes in the code for the button, you will see that you need to add the dynapdf.dll to your windows system32 folder in order for the code to work properly.

Notes:
You originally stated that you were using Access 2003:
<Create a PDF from a report without prompts - Access 2003>
...but now you say you are using Access 2010:
<I have tried this on my PC, which Access 2010,>
Then code contain aspects specific to Access 2003 (like turning the screen off, because the "Open Hidden" option was not available for Reports in Access 2003)
So in this case it is more of the "Format" of Access you are using, not really the version.
So My presumption is that you have at least one user still running Access 2003, so there is no need to modify the code.
But to be clear,  the code will run fine, unmodified, in most versions of Access.
Just an FYI

;-)

JeffCoachman
0
 
rick_dangerAuthor Commented:
Jeff
It wasn't a criticism, just an observation. I appreciate that I had asked for an A2003 solution, but I've not been able to try that yet. That was all I had to test it on immediately.

I'll be able to test it tomorrow.

Thanks again
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
rick_danger
Do you want me to post a procedure for setting this up - noting what I said in my FYI post above ?
0
 
Jeffrey CoachmanMIS LiasonCommented:
<It wasn't a criticism, >
I did not take it as criticism...
;-)

I just wanted you to know that the sample was specific to 2003, and that you needed to have the dll in a specific location.

I just want to make sure that the sample works OK for you first, ...then it can probably be adapted for your situation (using the counter)

So keep us posted.
;-)

Jeff
0
 
Jeffrey CoachmanMIS LiasonCommented:
<Do you want me to post a procedure for setting this up - noting what I said in my FYI post above ? >

Yes, Joe, ...
The more samples the better...
;-)
Always bet to have multiple alternatives...
;-)

Jeff
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
I will wait to hear from Rick - again after he reads my FYI post.
Leban's should work. However, "I have tried this on my PC, which Access 2010, " ... and that my be his issue. Again, seems I recall an issue running Leban's with and MDB in A2010 environment.
0
 
rick_dangerAuthor Commented:
This is A2010 - When I run it, it seems not to produce any output. When I go step-by-step, it goes to these lines:
s = "Sorry...cannot find the DynaPDF.dll file"
s = s & "Please copy the DynaPDF.dll file into the same folder as this Access MDB or your Windows System32 folder."
s = s & "Please copy the StrStorage.dll file into the same folder as this Access MDB or your Windows System32 folder."

Both files reside in the same folder as the Access database.
0
 
Jeffrey CoachmanMIS LiasonCommented:
<Both files reside in the same folder as the Access database. >
These files really need to live in the system 32 folder, else for each db that need this functionality you need to add the dll to each folder each db file lives in...

I put both files in System 32 folder and this works fine in Access 2003, 2007, 2010 and 2013...
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Don't you have to set a Reference to the DLL ?
0
 
rick_dangerAuthor Commented:
Tried it both ways, still same problem. It doesn't produce a PDF. If I have to set a Reference, how do I do it. If i go to Tools / References and Browse the 2 dlls do not appear in the list, even though they are now in the Windows / System 32 folder.
0
 
Jeffrey CoachmanMIS LiasonCommented:
<It doesn't produce a PDF. >
Are you sure?
...in your code, check the destination.

Does the code even run?


And to be clear, ...Does my database, as posted, work?
Yes or No?

Does the Lebans sample from his site work?

Again, this all works fine for me in Access 2010


If this is just an issue with your database, then can you post a sample.

But if you don't have the time, ask MX to post his solution...

JeffCoachman
0
 
rick_dangerAuthor Commented:
It's the very copy you sent me. The code runs, but doesn't produce output, and produces those lines of error as posted previously, all related to the DLLs, These are now in the Windows folder.
0
 
rick_dangerAuthor Commented:
Jeff
OK - I now have it working, but only with the DLLs in the database folder.

Thanks for the solution.
0
 
rick_dangerAuthor Commented:
Good solution!
0
 
Jeffrey CoachmanMIS LiasonCommented:
Glad I could help...
;-)
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
!
0
 
Jeffrey CoachmanMIS LiasonCommented:
?
0
 
rick_dangerAuthor Commented:
Don't know if those last 2 comments are meant to mean anything, but the code only works if the DLLs are in the database folder. This was the only reason it didn't originally work.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Actually, the !  was meant as follows:
You never responded to any of my posts :-(

mx
0
 
Jeffrey CoachmanMIS LiasonCommented:
rick_danger,

MX has a point.

It is standard practice to at least reply t all experts.

Even if you don't agree with the methodology, at least you can say so.
It just a common courtesy.

I hate when it happens to me too...

So you can reopen the question if you like, then try MX's suggestions.
You may even find his solution to be more elegant than mine.

At the very least you will have another point of view.
Which is always a good thing.

;-)

JeffCoachman
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
no need to re open .... thx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 9
  • 8
  • 8
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now