Preview Report before Msg Box

cariengon

New member
Local time
Today, 06:08
Joined
Nov 7, 2001
Messages
5
My code is attempting to preview a report, then run a msgbox that asks the user if they want to print the report. In the code, the msgbox appears immediately after the report opens in preview mode. I have tried SelectObject and GetFocus, etc. but the Report cannot be manipulated until the Yes or No has been choosen (then of course the rest of the code runs...)

Is there a way to pause, or allow the user to view the Report preview and then answer the msgbox? I figure I can do a preview with a form, but I wanted to avoid this if I could.

My code is below:

Private Sub cmd_Run_5500_Only_Click()

Dim MyMsgBox
'Need to figure out how to Preview the
5500 Report before printing
'DoCmd.OpenReport "300_rpt_GWLA_5500_
Indiv", acPreview
'[Reports]!
[300_rpt_GWLA_5500_Indiv].SetFocus

MyMsgBox = MsgBox("Do you want to print the cover letter and GWLA 5500
Report for Plan # " _
& [Forms]![300_frm_ParametersforQueries_Indiv]![ctl_PLAN_NBR] & "?",
vbYesNo, "Print 5500")

If MyMsgBox = vbYes Then
'change acPreview to acNormal to actually print.
DoCmd.OpenReport "200_rpt_LettertoPolicyHolder", acPreview
DoCmd.OpenReport "300_rpt_GWLA_5500_Indiv", acPreview
'DoCmd.Close acReport, "200_rpt_LettertoPolicyHolder"
'DoCmd.Close acReport, "300_rpt_GWLA_5500_Indiv"
MsgBox ("The cover letter and GWLA 5500 Report for Plan # " _
& [Forms]![300_frm_ParametersforQueries_Indiv]![ctl_PLAN_NBR] _
& " has been printed."), vbInformation, "Printing Done"
Else
DoCmd.Close acReport, "300_rpt_GWLA_5500_Indiv"
End If

End Sub
 
Use a custom menu bar with a print button add the code to the button.
 
Thanks for such a quick reply!

This sounds like a good workaround.

How do I attach the code to the button? In the Control Properties, there is only a selection called 'On Action' which gives me a list of the Macro's, not the Event Procedures. Does it make a difference that I'm programming in Access 97?
 

Users who are viewing this thread

Back
Top Bottom