Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best Print Solution: DoCmd.RunCommand(340) ??

Status
Not open for further replies.

waldemar

Programmer
Nov 15, 2001
245
0
0
DE
Well.... nice reports we all put in those databases. But how about procedures for printing them out? I found to use this command:

DoCmd.RunCommand(340)

which call the Windows Standard Print Dialog, *but* behaves a little strange since you need to abort *twice* to get rid of the dialog (?).

Does anybody have a more elegant solution? The windows standard dialog is quite nice since it provides features like page selection etc., so reprogramming something similar is ridiculous....

Regards
waldemar
 
Since my question is basically the same as waldemar's, but no one has answered yet and it's been a while since he originally posted, I'd might as well put it in here in the hopes someone will see our questions and give us some help.

I need to use the standard Windows Standard Print Dialog, and thanks to waldemar, I can get it to appear when I click on my command button to print out my report, but it prints out the form, not the report. When using the command button wizard to create a button to print out my report, it gives me this code:

Code:
Dim
Code:
stDocName
Code:
As String
Code:
stDocName = "Rpt_TierTwo_Form"
DoCmd.OpenReport stDocName, acNormal

Where Rpt_TierTwo_Form is the name of the report I want to print. Using just the RunCommand from Waldemar, it obviously doesn't print out the report. So how can I combine the two so I get the Windows Standard Print Dialog, but it actually prints out what I want it to?

-cheese 47 is a magical number. 47 plus 2 equals 49. 47 times 2 equals 94. 49 and 94. 94 and 49. Relationship between 47 and 2: it's magic.
 
This is a total shot in the dark, but why not try putting it in the on open or on load of the report?? and put it so that if the person hit's cancel, it cancel's the report??

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Thanks, junior1544, that was a very sneaky idea, and it worked. For the on click event on my print button, I used this code:

Code:
Dim stDocName As String
stDocName = "Rpt_TierTwo_Form"
DoCmd.OpenReport stDocName, acPreview
    
DoCmd.RunCommand (340)

So it opens up the form, gives you the Standard Windows Print Dialogue, and actually prints out what you tell it to. It's not the prettiest printing method I've ever seen, but it gets the job done. Thanks again!

-cheese
47 is a magical number. 47 plus 2 equals 49. 47 times 2 equals 94. 49 and 94. 94 and 49. Relationship between 47 and 2: it's magic.
 
That isn't exacly what i was thinking, but as long as it's working for you:)

I'm getting better at figuring out way's around access's limitations...

alwell...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top