Pausing vb code execution in access

M

mgcasey

I am utilizing a macro to 'print' a report to an Adobe PDF
print server, thus creating a PDF file of the access
report. My problem is that I want to copy the file after I
print the file but the access print routine finishes
before the Adobe PDF creation is complete, thus crashing
my next line of code trying to copy the file because it
see's the file as not available. I can look in the print
queue and see when the adobe PDF routine is done, but how
to I pause execution of the code until this happens? I
tried a while..wend loop waiting for the queue to be
cleared but access quickly swallows up the available cpu
time in looping and stops the PDF creation, thus
practically locking up the machine. Any thoughts?
 
V

Van T. Dinh

Try placing about 3-4 DoEvents statement in the loop to return the control
back to the OS which should allow time for the PDF creation.
 
A

A C

You could try putting Access to "sleep" for a set period (eg 5secs), then
check the print queue, if not empty then "sleep" again etc. Keep looping
until its clear.

See the trusty Dev Ashish site http://www.mvps.org/access/api/api0021.htm
for the code.

Does someone know if the sleep code is CPU intensive? If it is then you
might be better off loopoing around using DoEvents until the print queue is
empty.

Regards
A
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top