Code for Error 2501

kgranneman

New member
Local time
Yesterday, 19:06
Joined
Dec 11, 2008
Messages
6
I created a form which triggers an email message. If the message is "closed" without saving or sending the system returns a 2501 error.
I trapped the error and entered handling code which works on my system with the full version of Access 2010. However when the database is packaged with Runtime 2010 and installed on another PC, the 2501 returns and the form locks. The only way out is Ctrl-Atl-Del.

I added code to Exit the Sub on Error but it still didn't work.

Can someone review this and tell me what's missing? Thanks.

Private Sub cmdbtn_email_Click()
On Error GoTo CancelError

DoCmd.Hourglass True
DoCmd.SendObject acReport, "rpt_FUVisits", "PDFFormat(*.pdf)", "", "", "", "Appointment Confirmation - Subject# " + Me!StudyID + " " + Me!VerID + " " + PtID, "", True, ""
Me!FUDate.SetFocus
DoCmd.Hourglass False
Exit Sub
CancelError:
If Err.Number = 2501 Then
MsgBox "The Appointment Confirmation has not been sent!", vbOKOnly, "Cancel Email"
Me!FUDate.SetFocus
DoCmd.Hourglass False
Exit Sub
End If
End Sub
 
Remember to resume -->
Code:
    DoCmd.Hourglass False

CancelError_Exit:
    Exit Sub

CancelError:
    If Err.Number = 2501 Then
        MsgBox "The Appointment Confirmation has not been sent!", vbOKOnly, "Cancel Email"
        Me!FUDate.SetFocus
        DoCmd.Hourglass False
    End If
    Resume CancelError_Exit
End Sub
 
I made the change. Now have to re-package and test on other PC.
I'll let you know the outcome.
Thanks for the reply.
 

Users who are viewing this thread

Back
Top Bottom