keep getting this error Run time error 2501 This SendObject action was canceled. (1 Viewer)

cursedeye

Registered User.
Local time
Today, 01:04
Joined
Oct 7, 2009
Messages
50
I keep getting this error

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?
 

Kryst51

Singin' in the Hou. Rain
Local time
Yesterday, 23:04
Joined
Jun 29, 2009
Messages
1,896
Duplicate, See Active Here.
 
Last edited:

wazz

Super Moderator
Local time
Today, 12:04
Joined
Jun 29, 2004
Messages
1,711
looks like the server delays got in the way and i deleted the thread that was responded to (this post came in three times). sorry to whoever responded there. this is the active thread now.
 

Kiwiman

Registered User
Local time
Today, 05:04
Joined
Apr 27, 2008
Messages
799
Howzit

You want to find the line that is causing the error. Put a stop in the code then step through using the F8 key. Take a note of the line that triggers the error and see if there is anything wrong.

Code:
Private Sub cmdMailTicket_Click() 
On Error GoTo Err_cmdMailTicket_Click 

[B]STOP[/B]

Dim stWhere As String '-- Criteria for DLookup 
Dim varTo As Variant '-- Address for SendObject 
etc
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 05:04
Joined
Sep 12, 2006
Messages
15,749
DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, -1

presumably this line is failing

when it fails it rasies error 2501
 

Users who are viewing this thread

Top Bottom