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
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