DoCmd.PrintOut problem

C

Christine Desmuke

Hello:

I'm using Access 2000 SR-1 on WinXP, and trying to code a button on a
form to print multiple copies of a particular report. The report
itself works fine, and I can print a single copy using
DoCmd.OpenReport "rptDeedofGift", acViewNormal. To print multiple
copies, I think I need to use DoCmd.PrintOut, but I can't get it to
work.

The command sequence :
DoCmd.OpenReport "rptDeedofGift", acViewPreview
DoCmd.PrintOut acPrintAll, , , , 2, -1

prints two copies of the _form_ on which the button is located.

Then I tried:
DoCmd.SelectObject acReport, "rptDeedofGift", True
DoCmd.PrintOut acPrintAll, , , , 2, -1

with the same result.

Somehow, focus is staying with the form rather than shifting to the
report when it opens, so PrintOut prints the still-active form rather
than the intended report. What am I overlooking?

Thanks,
Christine
 
F

fredg

Christine said:
Hello:

I'm using Access 2000 SR-1 on WinXP, and trying to code a button on a
form to print multiple copies of a particular report. The report
itself works fine, and I can print a single copy using
DoCmd.OpenReport "rptDeedofGift", acViewNormal. To print multiple
copies, I think I need to use DoCmd.PrintOut, but I can't get it to
work.

The command sequence :
DoCmd.OpenReport "rptDeedofGift", acViewPreview
DoCmd.PrintOut acPrintAll, , , , 2, -1

prints two copies of the _form_ on which the button is located.

Then I tried:
DoCmd.SelectObject acReport, "rptDeedofGift", True
DoCmd.PrintOut acPrintAll, , , , 2, -1

with the same result.

Somehow, focus is staying with the form rather than shifting to the
report when it opens, so PrintOut prints the still-active form rather
than the intended report. What am I overlooking?

Thanks,
Christine

Christine,
Either use all 3 lines:

DoCmd.OpenReport "rptDeedofGift", acViewPreview
DoCmd.SelectObject acReport, "rptDeedofGift", True
DoCmd.PrintOut acPrintAll, , , , 2

or.. don't open the report in preview, and set the last SelectObject
argument to False.

DoCmd.SelectObject acReport, "rptDeedofGift", False
DoCmd.PrintOut acPrintAll, , , , 2

Both of the above worked fine for me.
 
C

Christine Desmuke

fredg said:
Christine,
Either use all 3 lines:

DoCmd.OpenReport "rptDeedofGift", acViewPreview
DoCmd.SelectObject acReport, "rptDeedofGift", True
DoCmd.PrintOut acPrintAll, , , , 2

or.. don't open the report in preview, and set the last SelectObject
argument to False.

DoCmd.SelectObject acReport, "rptDeedofGift", False
DoCmd.PrintOut acPrintAll, , , , 2

Both of the above worked fine for me.


Neither worked for me. Using all three lines, the preview window
appeared, and half of a 'Now printing rptDeedofGift to [printer]'
window, but then Access locked up hard and I had to end-task; nothing
ever came out of the printer. (I tried a couple of different printers
to make sure that wasn't the issue, and the report does work when
opened as acViewNormal.)

Then I tried your second alternative (no preview, last SelectObject
argument False), and got error #2489: the object 'rptDeedofGift' isn't
open.

Other suggestions?

--christine
 

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