HillTJ
To train a dog, first know more than the dog..
- Local time
- Today, 00:37
- Joined
- Apr 1, 2019
- Messages
- 731
Hi, I have the following code on my form to preview a filtered report in front of a popup form. This works fine. However, what I'd like to do is upon closing the form, is to prompt the user as to whether they wish to print the report or export it. I like the idea of using the DoCmd.RunCommand acCmdPrint to pop up the "windows" print options. I have the latter code on the 'On Close' event of the report. I get the error Message' 2585'. When I try this. If anyone can assist I'd be grateful. Also if there is a better technique then I'm 'all ears'. PS - I copied and pasted in the latter routine but could not format it as code. I'd appreciate someone explaining how this is done again. Cheers
Code:
Private Sub BttnPrint_Click()
Dim strWhere As String
On Error GoTo BttnOpenReport_Click_Err
If Me.Dirty Then
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Select a Record to Print"
Else
strWhere = "TaskID=" & taskID
Forms![frmtask].Visible = False
DoCmd.OpenReport "rptHazard", acViewPreview, , strWhere
'DoCmd.RunCommand acCmdPrint
End If
BttnOpenReport_Click_Exit:
Exit Sub
BttnOpenReport_Click_Err:
MsgBox Error$
Resume BttnOpenReport_Click_Exit
End Sub
Code:
Private Sub Report_Close()
DoCmd.OpenReport "rptHazard", acViewPreview, , strWhere
DoCmd.RunCommand acCmdPrint
Forms![frmtask].Visible = True
End Sub
Last edited: