OK, I tried what I had previously recommended, and it didn't work.
I also searched a variety of sources on the internet, and found nothing on
this subject. However, I did figure out something that seems to be working.
First, I created a function fnPrint( ) that I put in a code module. This
function looks like below, and returns a value indicating whether to continue
printing.
Public Function fnPrint(Optional PrintReport As Variant = Null) As Boolean
Static myValue As Variant
If IsEmpty(myValue) Then myValue = True
If Not IsNull(PrintReport) Then
myValue = PrintReport
End If
fnPrint = myValue
End Function
Next, I configured the command button on my form as follows.
1. Give it a caption that reads "Open &Report" or something like that
2. In the click Event of the button I entered code that looks like:
Private Sub cmd_Report_Click
IF me.cmd_Report.Caption = "&Cancel" Then
Call fnPrint(False)
me.cmd_Report.Caption = "Open &Report"
Else
Call fnPrint(True)
me.cmd_Report.Caption = "&Cancel"
docmd.OpenReport "reportName"
Endif
Endif
3. Then, I opened my report in design view. In each section of the report
(ReportHeader, PageHeader, Detail, PageFooter, ReportFooter), I selected
Format event, and entered the following code in that event. If you have
groupings in your report, you will also have to enter this code in the format
of the group headers and footers.
Me.PrintSection = fnPrint()
When I click the button, it opens the report and prints it directly to the
printer. If I click the Cancel button, it appears to interrupt that process
at whatever page has already been formatted.
Unfortunately, I don't have any reports that generate lots of pages, so I
was unable to test this with more than just a small data set. Let me know if
this works for you.
--
HTH
Dale
Don''t forget to rate the post if it was helpful!
email address is invalid
Please reply to newsgroup only.