print selected from print preview?

H

HX

I have a small application in Access 2000 that generally hides Access from
the user. They can import data and print it in the required format. I've
just added the ability for the user to see the report before it's printed
simply by adding a button that opens the report in print preview mode, and
added a print button to my custom toolbar. Problem is, clicking the print
button defaults to printing ALL the pages - there isn't even a prompt!

How can I give the user the Print Dialog window from a report's Print
Preview page?

Access and VB aren't what I normally do, so if you're going to suggest
coding something, I'd greatly appreciate details!

Thanks much for any help in this.
 
A

Arvin Meyer [MVP]

It could be coded, but the easiest way is to simply use the menu:

File >>> Print
 
H

HX

Yes... unfortunately, I have the menu hidden because this particular client
is painfully computer illiterate. The less I give them, the less changes
they are going to end up in some situation where I have to walk them through
over the phone.

I figured out that I could create a custom toolbar button and assign a macro
SendKeys of %P to open the print dialog, which was a step in the right
direction. Now, however, I've realized that I can't seem to give them the
Print dialog that I WANT ... by default they are getting the one with option
to print pages FROM and TO as a range, when I wanted to use the one that
gives the option to print Current or a range such as 2-14, 21, 33. Any
idea how to get that particular print window for a report??
 
A

Albert D. Kallal

I usually place two custom buttons on the report menu bar. (and I actually
take most of the preview menu items..and place that on the custom menu bar.

I then specify this menu bar for all reports. The code that the menu bar
buttons use is below:

The select object command is needed to fix a "focus" bug if you have a form
with a timer function.

For the code that pops up the printer dialog (so the user can change
printers, start/end page etc).

You can use:

On Error Resume Next
DoCmd.SelectObject acReport, Screen.ActiveReport.Name
DoCmd.RunCommand acCmdPrint

If you don't have forms with a timer, then just use:

DoCmd.RunCommand acCmdPrint

The code to print right to the printer while in preview mode can be:

On Error Resume Next
Dim strReportName as string
strREportName = Screen.ActiveReport.Name
DoCmd.SelectObject acReport, strReportName
DoCmd.PrintOut acPrintAll

YOu can see a picture of my custom menu bar here, and the first two buttions
run the above code:

http://www.members.shaw.ca/AlbertKallal/test/test.htm
 
A

Arvin Meyer [MVP]

From a form, if you use the following code from a command button, it will
open the print dialog:

Private Sub cmdPrint_Click()
DoCmd.RunCommand acCmdPrint
End Sub

The problem is that it won't work for a report. The PrtDevMode property will
allow you to do most of the things on the print dialog, but not which pages
to print. The dialog that you are looking for is not available in Access.
The one you mention below (2-14, 21, 33) is a Word only print dialog. It is
possible to export the entire report to Word and print it from there, but
certain elements like graphics will be lost.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top