Print report from VBA

C

Chrissy

Upon closing a form I question user if report has been
printed. If not, I want to force the printing of it right
there.

I use DoCmd to open and view the report while the form is
in use. Works fine and the user can print there. However,
I want to print if necesary without user viewing and
printing -- just print.

DoCmd PrintOut seems wrong; does not capture the report.
I see DoCmd.RunCommand acCmdPrint but don't know how to
get it (if that's the best way) to print the report
associated with my form -- stLinkCriteria.

Any help, as always, is most welcome.
Thanks,
Chrissy
 
S

Steve Schapel

Chrissy

If MsgBox("Did you print?", vbYesNo) = vbNo Then
DoCmd.OpenReport "YourReport"
End If
 
C

Chrissy

Thanks Steve.

I get a print window, but nothing goes to the printer.
The print window says its printing my report.

Any ideas?

Thanks,
Chrissy
 
S

Steve Schapel

Chrissy,

In my experience, the most common cause of this is that the report is
trying to go to the wrong printer. In design view of the report, go to
the File|Page Setup menu, and see which printer it is configured for.
If it's "default printer", then make sure the actual printer you are
trying to use is indeed the system's default printer.
 
C

Chrissy

Again, thanks.

I did check, its all correct. I substituted another
report and its working fine. So my problem appears to be
this report. I compare the two and find no obvious
differences that, to me, would affect printing.

Recall that I do get the printing message even when its
does not print; but functionally the printing procedure
has been proven.

Anything you can offer . . .

Thanks,
Chrissy
 
S

Steve Schapel

Chrissy,

Hmmm. Not much comes to mind. I think you would get the effect you
describe if the report has no data, and you have code on the report's On
No Data event property to cancel the print. Does this seem like a
possibility? Check the query that the report is based on... if the
amount of data being returned is really huge, I suppose it could happen
that the report is too large for the printer's memory to cope with, or
else it is just taking a really long time for the report to format.
Otherwise, try changing the code to open the report in Preview. If that
works, from the preview try pressing Ctrl+P and then print, and see if
it goes.
 
C

Chrissy

I will look at that. User already view the report and
(hopefully) prints elsewhere. I wanted to force the print
if not already done. BTW, short report, minimal data.

I'll just force the preview instead.

Thanks for your help, Steve.
Chrissy
 
S

Steve Schapel

Chrissy,

I am sorry I have been unable to hlep you here. This is most peculiar
behaviour you are experiencing. The best I can suggest now is for you
to re-post the question to the microsoft.public.access.reports
newsgroup, someone there might have a clue. In the meantime, I'll ask
around. Just to confirm... this report does in fact print correctly if
you try by other means, e.g. open it in preview and then click the Print
toolbar icon, or via the File|Print menu, right?
 

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