Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / August 2006

Tip: Looking for answers? Try searching our database.

Error on sending email

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Doug_C - 16 Aug 2006 14:56 GMT
Hello,

I have some code attached to a cmdButton so that a user may send an email
from the form with the information from the current record. The code and
button works perfectly! However, if the user clicks the button an the email
appears and the users chooses NOT to send it after all, they get an error.

Here is the error they get:

Run Time Error '2501'

The SendObject action was cancelled.

Here is the code:

Private Sub Command39_Click()
Dim SendTo As String, MySubject  As String, MyMessage As String
SendTo = ""
MySubject = "Issue"
MyMessage = Me.LoanNumber & vbCr & Me.CustomerFirst & " " & Me.CustomerLast
& vbCr & Me.ErrorCode & _
                     vbCr & Me.Comments
DoCmd.SendObject acSendNoObject, , , SendTo, , , MySubject, MyMessage, True

End Sub

Could someone please tell me how I can stop getting this error if they
choose not to send the email after clicking the button? Also, could you
please tell me where in this code it would go?

Thank you in advance!!
Nick 'The database Guy' - 16 Aug 2006 15:54 GMT
Hi Doug,

Firstly I have got to say that I am unaware of any code at the moment
that will send an email from access that does not first ask the user to
confirm that they want to send.  So that leaves us with the jbo of
tidying up the error.  I suggest something like:

Private Sub Command39_Click()
On Error GoTo err_
Dim SendTo As String, MySubject  As String, MyMessage As String

<<Code Body>>

Exit Sub

err_:
Select Case Err.Number
   Case 2501
       Msgbox "The mail has not been sent"
   Case Else
       MsgBox "An error occured.  Please check for obvious reasons
and/or technical support" & vbNewLine & "Error " & Err.Number & " : " &
Err.description, vbExclamation
End Sub

> Hello,
>
[quoted text clipped - 27 lines]
>
> Thank you in advance!!
Doug_C - 16 Aug 2006 17:55 GMT
Hi Nick,

When I placed the code in, it turned red on this part:

and/or technical support" & vbNewLine & "Error " & Err.Number & " : " &

I really do not need to have a message pop up, I just don't want the error
to pop up. If there is a way to prevent it that would be great but if not, I
will instruct everyone not to click the button unless they are sure they want
to send an email.

Thanks Nick!!

> Hi Doug,
>
[quoted text clipped - 52 lines]
> >
> > Thank you in advance!!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.