bypassing print wizard

MarkGardner

Registered User.
Local time
Today, 03:32
Joined
Mar 27, 2008
Messages
43
In using a form as a menu with macros, how can I select a print job from the menu choice and get it to print a report without the print wizard popping up?
 
DoCmd.OpenReport should print the report straight to the default printer, with the proper arguments.
 
Thanks for the solution. I am already using "OpenReport" in my macro. I do not see where to place the "DoCmd.OpenReport". Is that a VB command? I struggle with VB and have not yet figured out how to place a VB command in a macro unless it is already on the list of "Actions" that are on the list. Any further advice?
 
Are you using the "Print" view. Yes, what I posted is VBA. I don't use macros, but I would assume that the Print view would go straight to the printer. What Access version?
 
I use PrintOut action in Macro after OpenReport and it goes straight to printer
 
I struggle with VB and have not yet figured out how to place a VB command in a macro unless it is already on the list of "Actions" that are on the list. Any further advice?

Adding code is similar to adding a macro to a form. If you go to a button, field, label or the form itself and property Event you will see 3 dots just to the right of where you enter macro name and that drop down arrow.

If you click on the 3 dots and there is a macro already there then you will see the macro open in Design view. So go to something like a field/textbox where you don't have a macro and to its Event property. Pick the Event and click the 3 dots and a box will open and one of the options is Code Builder. Click Code Builder and a screen will open that shows something like

Private Sub Label291_Click()

End Sub

The code goes in between. In this case it would attach to Label291 and is for OnClick.

You can't run code like above from a macro because such code is part of the form. To run code from a macro the code must be in a module and then the function name (not module name) is done from the macro with RunCode action and FunctionName()

A Module is similar to a Macro except it has code instead of macro actions. As you know if you make a macro to open a form then you can use that macro all over the data base. Code that is in a module is the same.

The code you place in this example

Private Sub Label291_Click()

End Sub

is part of the form. If you exported the form then the code would come with the form.

If someone posts an answer that looks similar to this

Public Function

Full of code

End Function

that goes in a module, not to an event on a form. Public means...to use wherever, just like a macro.

The major difference between code and macro is code allows much more to be done. Macros are a little like a motor mechanic whose work is limited by the parts which are available. Code would be like a motor mechanic who can actually make parts that are not available over the counter.
 
pbaldy & Mike 375: Thanks for your input.

I am using Access 2007 and what I did was to consider info from both of you and varied it to get it to do the job.

In the macro "Action" I selected "RunCommand" option which I already had and what I assume to be the equivalent of the VB command "DoCmd" after the "OpenReport" action and in the argument section, I selected "Print" instead of the "Report" selection which was there previously.

It did take off and print without me making a choice in the print wizard.

Mike375:
However.... the print wizard did pop up anyway during the printing of the report and remained until I hit cancel. In looking at my macro, the next line is a "Close" in the action line.

I have expernimented with several options in the argument section of the "Close" action to see if it would close the print wizard on its own, but have been unsuccessful. Even though the report prints, I cannot get it to close the print wizard on its own within the macro.

Any ideas?
 
Solved!!!!

I simply went into my macro and eliminated the 2nd line of the macro action which read, "RunCommand" and the argument that was with it which was "Print". I realized that the "OpenReport" action had a secondary arguement after the first part that also read "Print". So what was happening was that it was printing with the first print command then setting it up to print a second time and that was what I was having to close. End of story. Thanks again for the guidance.
 

Users who are viewing this thread

Back
Top Bottom