Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect if a previewed report has been physically printed

Status
Not open for further replies.

r15gsy

IS-IT--Management
Jan 9, 2008
22
I have a db which produces several draft calculations on a report. The user may preview and change the criteria many times and preview the report.

When the report is physically printed I want my db to recognise it has been printed and then run some SQL to lock down the calculations.

What event on a report can be used to detect when a previewed report is sent to the printer.
 
I think you can check using the report's Activate and Deactivate events and in the report's header Print event. I believe these values may be different depending on if the report is previewed or printed.

Duane MS Access MVP
Now help me support United Cerebral Palsy
 
Dhookom

Thanks for the quick reply, I am not sure what I am meant to do to check the report's activate and deactivate events? Can you provide some example code or similar?

For now I have a workaround, but would prefer some neat code.

I have created a custom toolbar and copied all the buttons from the 'normal' print preview toolbar. Then I replaced the print button with a macro which calls some code:

Code:
Public Function PrintClaim()
On Error Resume Next

'Open a print dialog so user can print report
'Set as printed on print dialog box

DoCmd.RunCommand (acCmdPrint)
Forms!frmclaimdetail.intPrinted = -1

End Function

Code:
Private Sub Report_Close()
'Ask user if they want to mark as processed

Dim vbinput

If Forms!frmclaimdetail.intPrinted = -1 Then

    vbinput = MsgBox("Do you want to mark this claim as processed?", vbYesNo, "Processed")
    
    If vbinput = vbYes Then
        DoCmd.OpenQuery "qry1_aClaimDetailNotClaimedAppend"
        Else
        'do nothing
    End If
    
    Forms!frmclaimdetail.intPrinted = Null
    
    Else
    'do nothing

End If
    
'Restore from maximise view
DoCmd.Restore
    
End Sub
 
The Activate event of the report seems to be triggered only during the preview of a report. I tried this code in a report to test with an unbound text box in the report footer named txtActivate:
Code:
Option Compare Database
Dim booActive As Boolean

Private Sub Report_Activate()
    booActive = True
End Sub

Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
    Me.txtActivate = IIf(booActive, "Active", "not Active")
End Sub
When I printed the report following a preview, the report displayed Active. When the report was printed without first previewing, the report displayed not Active.

Don't know if this solves your issue but might help ;-)

Duane MS Access MVP
Now help me support United Cerebral Palsy
 
Just curious why you do not use a form so the calculations and changes can be made and viewed without viewing the report each time. And then have a button on the form that will print the report and also save the information on the form into a table.

Since you said:
When the report is physically printed I want my db to recognise it has been printed and then run some SQL to lock down the calculations.


ck1999
 
Hi ck1999

I like the idea, but my report has a lot of calculations which are shown in a report with 4 nested group headers/footers and the user needs to preview the report to see the results.

I don't think I could achieve the same directly in a form - I would have to use a form, with several subforms for the details in each group, and it would be harder to read.

All I really want to record is when the user presses print, so my workaround is doing the business at the moment.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top