Solved

Access MDB/PDF

Posted on 2016-11-24
21
28 Views
Last Modified: 2016-12-01
I've got an application running in an old version of Access (have to leave it there because of the toolbars), which I've been using pdf995 to print invoices.
The trouble is, the pdf995 runs async and doesn't notify back to access vba when its finished (it just sends a sleep() call and hopes) and the invoice routine is a batch and sometimes a new invoice gets printed into a the wrong pdf file, with extreme agony to all concerned as you can imagine.
Is there a pdf printing mechanism available to the old Access which somehow copes with synching back to the vba?
0
Comment
Question by:Silas2
  • 8
  • 7
  • 3
  • +3
21 Comments
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
I don't use Access much (old or new), but you could have Pdf995 name the PDF based on the original document name, which is surely unique, containing the (unique) invoice number. You'll need to use PdfEdit995 for this, which is part of the Pdf995 Suite. The file naming feature that you'll use is #9 at this page:
http://www.pdfedit995.com/

Specifically, 9.b.:
Automatically name the document based on the originating document and save it in the pdf995\output folder.
Using that technique, a new invoice will never get printed into the wrong PDF file — each one will always be in its own PDF file. Regards, Joe
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
0
 
LVL 18
Comment Utility
here is a free tool to write Reports to PDF by Lebans
http://www.lebans.com/reporttopdf.htm
0
 

Author Comment

by:Silas2
Comment Utility
The shellandwait looks interesting, the only thing is the process is not as easy to disentangle because the invocation is simply : OpenReport (and the report's printer is set to pdf995)
That's where the trouble starts, if pdf995 hasn't finish the previous report when a new report is sent to it, it just stamps the new one into the one being made.
That's why tinkering with filename changes doesn't get round the problem. I'm not sure if sending it to a new folder might work.....although looking at the code, pdf995 does spit out a finished flag....I've only just had the screaming phone call, trouble is, its a very difficult issue to replicate, when you step thru the code it never does it...
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
> That's why tinkering with filename changes doesn't get round the problem.

Doesn't the original file, i.e., the invoice from which the PDF is being created, have a unique file name?
0
 

Author Comment

by:Silas2
Comment Utility
Each report has a unique name but pdf995 does not finish one file before the vba has squirted more stuff in from a different report.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
> Each report has a unique name but pdf995 does not finish one file before the vba has squirted more stuff in from a different report.

Unless I'm not understanding the process, that doesn't matter if each source file, and the PDF created from each one, have different/unique names, as you can do with PdfEdit995.

P.S. Leaving for Thanksgiving dinner now. Will check back into the thread tomorrow.
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
Comment Utility
<<That's where the trouble starts, if pdf995 hasn't finish the previous report when a new report is sent to it, it just stamps the new one into the one being made.>>

 I use my own variation of ShellAndWait() and I don't have issues.    I haven't worked with pdf995 specifically though (I use a printer driver with PS output, then use GhostScript to convert it to a PDF),  but what you want to do is set the printer to not allow spooling.  That should take care of that problem.

Jim.
0
 
LVL 13

Expert Comment

by:John Tsioumpris
Comment Utility
Lebans solution mentioned by crystal...is quite good although not perfect...i think you should take a look...we having being using if for years....for everything from invoices to technical documents....it has some issues but usually they are related to machines who have a lot of background tasks....
Also if you don't mind doing some tests...PDF Factory has a server edition which has proven to be stable and has many features....if you insist on something free PDFCreator is also nice but needs extra tweaking
If i remember correctly PDF995 was limited and cumbersome so some testing won't hurt
0
 

Author Comment

by:Silas2
Comment Utility
Thanks, I'm just waiting for the mdb to turn up snail/mail so I can see if i can replicate. That is a problem with my favourite old workbench - the files are local and just grow and grow.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 18
Comment Utility
> "the files are local and just grow and grow"

do you compact/repair on a regular basis? This should only be done right after the database is backed up.
0
 

Author Comment

by:Silas2
Comment Utility
These mdb's seem to be so resilient. I do tend to make a purge/year end function, so they shouldn't grow that big but even 100mb is quite a small one, and have you found a way of getting that over a slow internet connection?
0
 
LVL 18
Comment Utility
zip and upload to a website. Then once it is downloaded, overwrite file on the website with another one having the same name (such as temporary.zip). Alternately you can use something like DropBox, which I personally don't like but others use it.
0
 

Author Comment

by:Silas2
Comment Utility
Wow, I've just noticed the VBA code from the pdf995 website isn't properly setting and unsetting the 'busy' flag , thats why it was always ok to start another. There is another sample in a different language with a clearer 'end of print process app to run' . I've got that faulty sample code running elsewhere as well....i wonder if I should alert them....
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
> i wonder if I should alert them

Absolutely! I'm sure they'll be grateful.
0
 

Author Comment

by:Silas2
Comment Utility
But its been running for 5-10years without any complaint!

The reason I think it just sprang a leak out of the blue is that there is 5 second delay before it checks the flag, and an old PC must have suddenly breached the 5 seconds.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
> But its been running for 5-10years without any complaint!

Doesn't matter. A bug is a bug. They'll want to know about it. I still don't understand your process...seems to me that different filenames for the created PDFs avoids the problem, but that's a different story.
0
 

Author Comment

by:Silas2
Comment Utility
Different names doesn't solve it, its a single process running async, if you send another file (with a different name) before the async process is complete, it stamps the new content into the unfinished file, it doesn't spin up a new process for the new file.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
Then the PdfEdit995 feature of automatically naming the PDF document based on the name of the source document (and then saving it in the Pdf995 output folder) doesn't have much value...hard to believe they would have built it that way.
0
 

Author Comment

by:Silas2
Comment Utility
It has a value, I name all files InvoiceXXX.pdf etc, but...that doesn't stop subsequent files from stamping their content in if the process isn't finished.

The issue is, http://www.pdf995.com/faq_dev.html, if you search for applicationthatdeletesflagfilethatyousupply on that page you can see the C++ version of clearing the flag, whereas the vba code:
http://www.freeware995.com/misc/vbacode.txt
In the line:
Do While ReadINIfile("PARAMETERS", "Generating PDF CS", syncfile) = "1"
Its checking the flag "Generating PDF CS" in the INI file, but that flag is never getting set (as far as i can see).
I copied the pattern from the C++ code and put a del cmd in  .bat file in for applicationthatdeletesflagfilethatyousupply, so make 'imbusy.txt' in VBA then delete with the .bat.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
OK, thanks for the explanation — much appreciated!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now