Access Print Problem

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

Hi Everyone-

I've set the default printer for my system to be an HP laser that has the
port set to FILE, so that all print jobs will prompt the user for a file
name. Within my Access application, in VB, I use the docmd to print the
report and as expected Windows displays the prompt to direct the output to a
file. Now, I've also found code on the internet that will allow me, again
within VB, to look for the open window (which is asking for the file name)
and automatically fill in the directory, filename. This process is designed
to automate the report and not have any user intervention of any sort.

However, I'm finding that Access will wait for the docmd to finish before
moving on to the next line of code, which in this case, checks for the print
window so that it can add the directory name, etc.

Question: Is there a way to tell Access not to wait for this process to
finish before moving on or perhaps set a timeout or is there a better way to
do this?


Scott
 
At a guess, you may be able to "Sendkeys" immediately PRIOR to executing the
docmd. This certainly works on printing to a PDF driver, though you don't know
whether it will ask to overwrite an existing file. The reason you can sendkeys
PRIOR is that keystrokes are not actioned until the OS get's a chance.

And this is fraught with danger. Many people have pop-up e-mail notifications
etc, etc. I guess that's why you are searching for the correct window. Seems
to me you are getting into a knot, because the window won't be there until you
execute your print.

There are two ways to print (the active object) depending on whether you want
to allow user-intervention

DoCmd.RunCommand acCmdPrint (ask)
DoCmd.PrintOut acPrintAll, , , acHigh, [nCopies], True (don't ask)

(except for printing to a file or PDF driver of course! I just let the user
handle the screen prompt, at least it suggests a default filename and whether
to overwrite)

Not sure if this helps or muddies things. A timer might be worth trying, you
tell us.
Chris
 
Back
Top