print issue (prints fine but then open the report???)

B

_Bigred

Hello Guys,


I have a form with command buttons set to print the designated reports.

I have used the following code as the "On Click" event

DoCmd.OpenReport "Unit Mail List", acViewPreview
On Error Resume Next
DoCmd.RunCommand acCmdPrint
Dim strRptName
strRptName = "Unit Mail List"
DoCmd.SelectObject acReport, strRptName, False


The code works fine, it gives me the printer dialog box so the user can
select the printer, #copies etc... but once it kicks the report to the
printer it opens the designated report???

How can I just have the code prompt the user for (printer, #Copies etc..)
but NOT open the report?

TIA,
_Bigred
 
F

fredg

Hello Guys,

I have a form with command buttons set to print the designated reports.

I have used the following code as the "On Click" event

DoCmd.OpenReport "Unit Mail List", acViewPreview
On Error Resume Next
DoCmd.RunCommand acCmdPrint
Dim strRptName
strRptName = "Unit Mail List"
DoCmd.SelectObject acReport, strRptName, False

The code works fine, it gives me the printer dialog box so the user can
select the printer, #copies etc... but once it kicks the report to the
printer it opens the designated report???

How can I just have the code prompt the user for (printer, #Copies etc..)
but NOT open the report?

TIA,
_Bigred

Why are you opening the report in preview?

Dim strRptName
strRptName = "Unit Mail List"
DoCmd.SelectObject acReport, strRptName, True
DoCmd.RunCommand acCmdPrint

If you don't need to select the printer or change printer properties,
you could use the PrintOut method

Dim strRptName
strRptName = "Unit Mail List"
DoCmd.SelectObject acReport, strRptName, True
DoCmd.PrintOut acPrintAll, , , , 1

If you need to have gthe user change the number of copies, you can use
a text control on your form to indicate the number of copies:
DoCmd.PrintOut acPrintAll, , , , Me![ControlName]
 
B

_Bigred

Hello FredG,

I used your code below and the print dialog popup works fine. The report no
longer opens after printing (like prob in Orig post).

But now when I click the "print button" that is on my switchboard form for
the particular report, it prompts for printer etc... like desired but then
it prints and drops the switchboard down so that the report list is visible
on the screen.

What do I have to do to keep the switchboard up on the screen, I don't want
it to minimize???

TIA
_Bigred
 
F

fredg

Hello FredG,

I used your code below and the print dialog popup works fine. The report no
longer opens after printing (like prob in Orig post).

But now when I click the "print button" that is on my switchboard form for
the particular report, it prompts for printer etc... like desired but then
it prints and drops the switchboard down so that the report list is visible
on the screen.

What do I have to do to keep the switchboard up on the screen, I don't want
it to minimize???

TIA
_Bigred

Once you select another object from the main database, in this case
the report, the form no longer has the focus. It is simply hidden by
the main folder.

Just add, under the DoCmd.RunCommand acCmdPrint line:

DoCmd.SelectObject acForm, "YourFormName", False
 

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