Programmatically Close Report

  • Thread starter Thread starter Mike
  • Start date Start date
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!
 
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.
 
Back
Top