Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    error handling (2000)

    Hello I have a button click that calls a procedure to populate an e mail, if that e mail is canceled I get an error messge that the action has been canceled, how can I build my code around this. If it is canceled I just want a record in my form to be deleted.

    Private Sub Command8_Click()

    On Error GoTo explain

    Call emailmessage



    Exit Sub

    Forms!tbchase!ChaseDate = Now()


    explain:

    If MsgBox("You have canceled the E mail, if this is correct click no or click ok to send", vbYesNo + vbQuestion) = vbYes Then

    Call emailmessage
    Else
    End If


    End Sub


    Private Sub emailmessage()
    ' to populate e mail
    DoCmd.SendObject to:="", Subject:="Chaser for IFA Lead Information From the Technical Helpline ID " & Forms!leadupdate!ID, _
    MessageText:=vbCrLf & vbCrLf & vbCrLf & "IFA Office:" & " " & Forms!leadupdate![IFA Office] _
    & vbCrLf & vbCrLf & "Contact Detail:" & " " & Forms!leadupdate![IFA Office] _
    & vbCrLf & vbCrLf & "Client:" & " " & Forms!leadupdate![Policyholder] _
    & vbCrLf & vbCrLf & "Quote/Business Details:" _
    & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & "PLEASE INFORM THL IF BUSINESS ACQUIRED" _
    , EditMessage:=True

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: error handling (2000)

    In general, when an action is canceled, error 2501 occurs. You can take care of this in the error handling section:

    explain:
    If Err = 2501 Then
    ' The action has been canceled. Insert appropriate code below.
    ...
    Else
    ' Another error occurred - report to user
    MsgBox Err.Description, vbExclamation
    End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •