Closing report after printing

Nimrod146

Registered User.
Local time
Today, 02:39
Joined
Feb 11, 2007
Messages
11
I may be overlooking the obvious on this one!!!

Recently I asked for assistance on printing the current report page only, from a command button ... I received a number of replies to which I thank all those who took the time. I added the relevant code amendment and it works great. However, when I click this button ... it prints the current page, but doesnt automatically close the report window afterwards.

I would appreciate any help as to how to close the report window after printing ... or print this record, without showing the report window in the first place.

Many thanks in anticipation.
Nimrod
 
Thanks for your help ............. I think this is one!


Private Sub Training_Agreement_Click()
On Error GoTo Err_Training_Agreement_Click

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "Training Agreement", acViewPreview, , "[RecordID] = " & [RecordID]

Dim stDocName As String

stDocName = "Training Agreement"
DoCmd.OpenReport stDocName, acNormal

Exit_Training_Agreement_Click:
Exit Sub

Err_Training_Agreement_Click:
MsgBox Err.Description
Resume Exit_Training_Agreement_Click

End Sub
 
Thanks for your help ............. I think this is one!


Private Sub Training_Agreement_Click()
On Error GoTo Err_Training_Agreement_Click

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "Training Agreement", acViewPreview, , "[RecordID] = " & [RecordID]

Dim stDocName As String

stDocName = "Training Agreement"
DoCmd.OpenReport stDocName, acNormal

Exit_Training_Agreement_Click:
Exit Sub

Err_Training_Agreement_Click:
MsgBox Err.Description
Resume Exit_Training_Agreement_Click

End Sub

Change acViewPreview to acNormal
 
Since when did the OpenReport method need the Close command?

The code came with creating a button on a report which prints the report.
Since the poster wants to close the report after printing I added the Docmd. close as to facilitate this.
I used the wizzard to create a report print button and added the .close, which worked perfectly.
 
DoCmd.OpenReport "reportname", acViewNormal ...
will print your report out to the paper w/o show the Print Preview window.

DoCmd.Close acReport, "ReportName"
will close your Print Preview window if it is loaded (visible or hide)
 
Many thanks for all your posts ... I'll try it out.

Regards
Nimrod
 

Users who are viewing this thread

Back
Top Bottom