I have some code on a button to print a query when clicked. Afterwords the print dialog box comes up. I want it to print without this box coming up or some code to just click ok automatically. All print settings have already been set in my code.
Click ok button on print box automatically
Collapse
X
-
Code:DoCmd.SetWarnings false
(I have not tested the following);Code:DoCmd.OpenQuery ("Anodic Unload Sheet Query") Application.Printer.Orientation = acPRORLandscape DoCmd.SetWarnings False RunCommand acCmdPrint DoCmd.SetWarnings true
-zComment
-
This doesn't work because the print box is not a warning. It is just the standard box for choosing print settings that you would see if you pressed Ctrl+P on a web page. I just don't want users to bother with that box and for it to print automatically after they push to print button on my form.Comment
-
try the following... it has been proofed.
Code:DoCmd.OpenQuery ("Anodic Unload Sheet Query") Application.Printer.Orientation = acPRORLandscape DoCmd.SetWarnings False docmd.printout DoCmd.SetWarnings true
theCode:RunCommand acCmdPrint
-zComment
-
The runcommand is just like if you clicked on the item in menu/ribbon.
The DoCmd is more like you're running one of the macro commands.
More than likely lines 3 and 5 for the warnings aren't needed... forgot to take them out when I tested
Never made sense to me why one has to use macro stuff in a VBA code other than sheer laziness on the part of the developers!
Being new... yep...
I have several of the "Inside/Out..." books dealing with Access and I also went thru http://msdn.microsoft.com/en-us/library/ee861519.aspx although it reads worse than stereo instructions. The rest of the programing comes from being a very old-school programmer... wrote my first programs using a stack of punch cards :) in COBOL... wow... how time flies when you get old, and have kids!
and I still stumble from time to time... that's why boards like this are so valuable - peers helping peers.... wish the world really worked this way as a whole!
-zComment
Comment