Automating Report Printing Trouble

M

Matthew

I have a report that I set to print "On Open" (in the event tab of the
report properties dialog) with the following code:

Private Sub Report_Open(Cancel As Integer)
DoCmd.PrintOut acPrintAll, , , , 1, True
End Sub

The problem is: when I open the report it tries to run the code then gives
me this message:

Run-time error '2585':
This action can't be carried out while processing a form or report event.

I have also tried a VB Module:

Function test()
DoCmd.OpenReport "NewCatalog", acViewPreview, "", "", acNormal
DoCmd.PrintOut acPrintAll, , , , 1, True
DoCmd.Close acReport, "NewCatalog"
End Function

This gave me the same error.

Any ideas?

Matthew
 
M

MacDermott

Try opening the report from a button on a form.
You can use the command button wizard to create a button which will print
your report.

HTH
- Turtle
 
M

Matthew

Thanks for the response. I found the problem.

Whoever created the report set it to run a second macro "On Print" and
something was wrong with that macro.

Matthew
 

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