I am trying to create a command button on a form that prints a report based on the current record's TaskID. below is the code I'm entered:
Private Sub Cmd75Letter_Click()
On Error GoTo Err_Cmd75Letter_Click
Dim stDocName As String
Dim stWhere As String
stDocName = "rpt75Letter"
stWhere = "[TaskID]=" & Me!TaskID
DoCmd.OpenReport stDocName, acViewPreview, , stWhere
DoCmd.RunCommand acCmdPrint
Exit_Cmd75Letter_Click:
Exit Sub
Err_Cmd75Letter_Click:
MsgBox Err.Description
Resume Exit_Cmd75Letter_Click
End Sub
When I click the button I get a message "Run Time Error 3464". When I click debug "DoCmd.OpenReport stDocName, acViewPreview, , stWhere" is highlighted. The TaskID is a text field on the form.
Please help solve this problem