Report Not Cancelled

S

Selwyn Young

When the user hits the print button while viewing a report, I want it to
refresh/add some values and then print. Refreshing means closing the
report and re-opening and I can't do this in the report without crashing
Access. So I stop the report from printing (cancel=true) and have a timer
on the main form that checks the value of ViewPrint to see if it should
be refreshed and printed.

The issue: Hitting the print button prints a blank report (blank page)
every time instead of being fully cancelled.

What's going on?

-- Report
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If Not CurrentProject.AllForms("frmReportsMenu").IsLoaded Then
If ViewPrint = 1 Then
Cancel = True
End If
ViewPrint = ViewPrint + 1
Else
ViewPrint = 0
End If
End Sub

-- Main Form
Private Sub Form_Timer()
If Not bolCustFocus Then
RefreshReport
End If
End Sub

Private Sub RefreshReport()
If ViewPrint = 2 Then
ViewPrint = 3
Result = modDockets.GetNumbers(CurrBatchNo,
Me.frmOrder.Form.OrderID)
DoCmd.Close acReport, "rptDeliveryDockets"
DoEvents
DoCmd.OpenReport "rptDeliveryDockets", acViewPreview
DoEvents
DoCmd.SelectObject acReport, "rptDeliveryDockets", True
DoCmd.PrintOut
End If
End Sub
 
F

fredg

When the user hits the print button while viewing a report, I want it to
refresh/add some values and then print. Refreshing means closing the
report and re-opening and I can't do this in the report without crashing
Access. So I stop the report from printing (cancel=true) and have a timer
on the main form that checks the value of ViewPrint to see if it should
be refreshed and printed.

The issue: Hitting the print button prints a blank report (blank page)
every time instead of being fully cancelled.

What's going on?

-- Report
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If Not CurrentProject.AllForms("frmReportsMenu").IsLoaded Then
If ViewPrint = 1 Then
Cancel = True
End If
ViewPrint = ViewPrint + 1
Else
ViewPrint = 0
End If
End Sub

-- Main Form
Private Sub Form_Timer()
If Not bolCustFocus Then
RefreshReport
End If
End Sub

Private Sub RefreshReport()
If ViewPrint = 2 Then
ViewPrint = 3
Result = modDockets.GetNumbers(CurrBatchNo,
Me.frmOrder.Form.OrderID)
DoCmd.Close acReport, "rptDeliveryDockets"
DoEvents
DoCmd.OpenReport "rptDeliveryDockets", acViewPreview
DoEvents
DoCmd.SelectObject acReport, "rptDeliveryDockets", True
DoCmd.PrintOut
End If
End Sub

The "Cancel = true" in the detail print event only cancels the
printing of that section, not the entire report.
The only place you can cancel the entire report is in the report's
Open event (Cancel = true).

As far as I know, you cannot close the report and open it again from
within the report. Close it. Then use a form event to make whatever
changes you wish, then open it again.
 
M

Michael Cheng [MSFT]

Hi Selwyn,

Would you please send me with a small sample of your project about what you
want to realized, with which I could reproduce it on my side? Send the
sample to (e-mail address removed) (remember to remove 'online' as
it's only for SPAM). More detailed information, I believe, will make us
closer to the resolution.


Sincerely yours,

Michael Cheng
Microsoft Online Partner Support

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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