Private Sub cmdPrintReport_Click()
[COLOR=SeaGreen]'prints selected massage via pre-made report
[/COLOR]
On Error GoTo Err_cmdPreviewCurrentMassageReport_Click
Dim stDocName As String
Dim strCriteria As String
stDocName = "rptHorseMassage"
strCriteria = "[MassageID]= " & Me![MassageID]
[COLOR=SeaGreen]
'open report with given variables[/COLOR]
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport stDocName, acPreview, , strCriteria
[COLOR=SeaGreen]'open the print dialog, then close report[/COLOR]
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, stDocName, acSaveNo
Exit_cmdPreviewCurrentMassageReport_Click:
Exit Sub
Err_cmdPreviewCurrentMassageReport_Click:
Select Case Err.Number
Case 2501
[COLOR=SeaGreen] 'command cancelled, close report[/COLOR]
DoCmd.Close acReport, stDocName, acSaveNo
Case Else
MsgBox Err.Description
End Select
Resume Exit_cmdPreviewCurrentMassageReport_Click
End Sub