Access report: switch printer and select tray before printing
Hello people.
The idea behind the following code is to open a report HIDDEN, change it's printer and tray, then open the report again normally so it prints.
Code:
'open report hidden
DoCmd.OpenReport stDocName, view:=acPreview, WindowMode:=acHidden, WhereCondition:="[NoPatient] = 8"
'set new printer (this part works)
Set Reports(stDocName).Printer = Application.Printers(strPrinterToUse)
'set paperbin to manual feed (this also works)
Reports(stDocName).Printer.PaperBin = 4
'open report normally so it prints
DoCmd.OpenReport stDocName, WhereCondition:="[NoPatient] = 8"
So here's my problem: on the last line of code (OpenReport), the report will show on screen! It should be sent straight to the printer. I tried using acHidden and did some trial and error on parameters, I can't find it out. Is there something wrong with the way I open it the first time around?
I'm happy it does select the desired printer and tray, but having the report (which is currently an invoice being printed out) pop out and show every time is somehow annoying.
My code seems to be following quite well different articles I've read. :(
Any help appreciated!
Thanks!
Re: Access report: switch printer and select tray before printing
Have you tried putting this:
Code:
DoCmd.RunCommand acCmdPrint
after the line where you set the paper bin?
Re: Access report: switch printer and select tray before printing
Thanks for your feedback.
I did try this out, it brings up the dialog box for printing... While I'd want the user to have no interaction at all.
Also tried acCmdQuickPrint (or something like that) but it ended up printing the form instead.
Currently my app does work, but you can see that report 'flashing' before being printed. Not very nice...
Re: Access report: switch printer and select tray before printing
Quote:
but you can see that report 'flashing' before being printed. Not very nice...
http://msdn.microsoft.com/en-us/libr...ice.15%29.aspx
HTH