Programmatically Close Report

M

Mike

Hi. I have a report that, when opened with OpenArgs, prints the number of
copies specified in OpenArgs. Shown here:

Private Sub Report_Activate()
If Len(Report.OpenArgs) > 0 Then
DoCmd.PrintOut acPrintAll, , , acHigh, Report.OpenArgs
End If
End Sub

I'm trying to programmatically close the report if OpenArgs exist. But no
mater which method I try (Load, Current, Deactivate, etc), I'm getting the
error
"Run-time error '2585'. This action can't be carried out while processing a
form or report event."

Private Sub Report_Deactivate()
If Len(Report.OpenArgs) > 0 Then
DoCmd.Close
End If
End Sub

I need to programmatically print and close a report if OpenArgs are
specified. Could someone please advise how to do this?

Thanks!
 
R

Rick Brandt

Mike said:
Hi. I have a report that, when opened with OpenArgs, prints the
number of copies specified in OpenArgs. Shown here:

Private Sub Report_Activate()
If Len(Report.OpenArgs) > 0 Then
DoCmd.PrintOut acPrintAll, , , acHigh, Report.OpenArgs
End If
End Sub

I'm trying to programmatically close the report if OpenArgs exist.
But no mater which method I try (Load, Current, Deactivate, etc), I'm
getting the error
"Run-time error '2585'. This action can't be carried out while
processing a form or report event."

Private Sub Report_Deactivate()
If Len(Report.OpenArgs) > 0 Then
DoCmd.Close
End If
End Sub

I need to programmatically print and close a report if OpenArgs are
specified. Could someone please advise how to do this?

Thanks!

If you don't open it in preview mode then there is no need to close it. Just
send it straight to the printer as many times as you want it printed.
 

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