Report opens and visible

A

AHopper

On a dialog box I allow the user to choose a "JobNumber"
they would like to print a report for. When the click
the "Print Report" command button they are asked if they
want to print only the last page. The report is printing
correctly, however, the report opens and becomes visible
behind the dialog box. Is there any way to keep this from
happening and/or have the report close when it has printed
the last page?
The following is in the "On Click" event.

Dim stDocName As String
stDocName = "SpoilageRemovedAtAnalysisRevised"
Answer = MsgBox("Do you want to print ONLY the last page
of the report?", vbYesNo + vbQuestion)
If Answer = vbYes Then
DoCmd.OpenReport stDocName, acViewPreview, , "[JobNumber]
=[Forms]![SpoilageAnalysisDialogBox]![JobNumber]"
DoCmd.SelectObject acReport, stDocName, False
DoCmd.PrintOut acPages, Reports!
SpoilageRemovedAtAnalysisRevised.[Pages], Reports!
SpoilageRemovedAtAnalysisRevised.[Pages]
Exit Sub
End If
If Answer = vbNo Then
End If

Thank you for your help

Allan
 
A

AHopper

Not certain if it is the best way but I made the following
changes and it works. I will watch to see if there are
other suggestions.

DoCmd.Hourglass True
DoCmd.Echo False
DoCmd.OpenReport stDocName, acViewPreview, , "[JobNumber]
=[Forms]![SpoilageAnalysisDialogBox]![JobNumber]"
DoCmd.SelectObject acReport, stDocName, False
DoCmd.PrintOut acPages, Reports!
SpoilageRemovedAtAnalysisRevised.[Pages], Reports!
SpoilageRemovedAtAnalysisRevised.[Pages]
DoCmd.Close acReport, stDocName
DoCmd.Hourglass False
DoCmd.Echo True

Allan
 

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