I keep getting this error
Run time error 2501
This SendObject action was canceled.
This is my code:
Run time error 2501
This SendObject action was canceled.
This is my code:
Private Sub cmdMailTicket_Click()
On Error GoTo Err_cmdMailTicket_Click
Dim stWhere As String '-- Criteria for DLookup
Dim varTo As Variant '-- Address for SendObject
Dim stText As String '-- E-mail text
Dim PlanDate As Variant '-- Rec date for e-mail text
Dim stSubject As String '-- Subject line of e-mail
Dim stWorkOrderID As String '-- The ticket ID from form
Dim stWho As String '-- Reference to Employees
Dim stPlanner As String '-- Person who assigned ticket
Dim strSQL As String '-- Create SQL update statement
Dim stWorkDescription As String '-- Work description
Dim errLoop As Error
'-- Combo of names to assign ticket to
stWho = Me.AssignedTo.Value
stWhere = "Employees.EmployeeID = " & stWho
'-- Looks up email address from Employees
varTo = DLookup("", "Employees", stWhere)
stSubject = ":: New Work order ::"
stWorkOrderID = Format(Me.WorkOrderID, "00000")
PlanDate = Me.PlanDate
'-- planner employee who assigns ticket
stPlanner = Me.PlannedBy.Column(1)
stWorkDescription = Me.Description
stText = "You have been assigned a new work order." & Chr$(13) & _
Chr$(13) & "Work Order Number :" & stWorkOrderID & Chr
$(13) & _
"This Work Order is planned by: " & stPlanner & _
Chr$(13) & "Plan Date: " & PlanDate & Chr$(13) & _
Chr$(13) & "Work Description: " & stWorkDescription & Chr
$(13) & _
Chr$(13) & "This is an automated message." & _
" Please do not respond to this e-mail."
'Write the e-mail content for sending to assignee
DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, -1
Exit_cmdMailTicket_Click:
Exit Sub
Err_cmdMailTicket_Click:
Select Case Err.Number
Case 2501
Err.Clear
MsgBox "You chose to cancel."
Case Else
MsgBox Err.Description
End Select
Resume Exit_cmdMailTicket_Click
End Sub
[/QUOTE]
Can you tell me where went wrong?