reset Run Time 2501

G

Guest

I am trapping the 2501 Error after someone closes an email without sending
it. So in the ErrorRoutine, I am asking them to send it. If they click
okay, then it runs SendObject again. However if they close it without
sending it again, the END/DEBUG dialog box with RUNTIME ERROR 2501 shows up
again.

I have tried ERR.CLEAR but it doesn't help.

Below is part of my code. Anyone have any ideas?

************** Code Snippet Start ***************************
SendIt:
DoCmd.SendObject acSendNoObject, strBody, acFormatTXT, _
sAddress, , , "New Stuff", strBody, True

RoutineExit:
GoTo AddAgain:

ErrorRoutine:
If Err.Number = 2501 Then
Msg = "Yada Yada 1 " & vbCrLf & _
"Yada Yada 2" & vbCrLf & vbcrlf & _
"Yada Yada 3"
Style = vbYesNo + vbDefaultButton1
Title = "Please Send"
Response = MsgBox(Msg, Style, Title)
If Response = vbNo Then
GoTo AddAgain:
Else
GoTo SendIt:
End If
Else
MsgBox "Error number: " & Err.Number & vbCrLf & vbCrLf & _
Err.Description, vbCritical, "Error"
End If

Resume RoutineExit
....
************** Code Snippet End *******************************



TIA

Vanya
 
M

Marshall Barton

Ivan Grozney said:
I am trapping the 2501 Error after someone closes an email without sending
it. So in the ErrorRoutine, I am asking them to send it. If they click
okay, then it runs SendObject again. However if they close it without
sending it again, the END/DEBUG dialog box with RUNTIME ERROR 2501 shows up
again.

I have tried ERR.CLEAR but it doesn't help.

Below is part of my code. Anyone have any ideas?

************** Code Snippet Start ***************************
SendIt:
DoCmd.SendObject acSendNoObject, strBody, acFormatTXT, _
sAddress, , , "New Stuff", strBody, True

RoutineExit:
GoTo AddAgain:

ErrorRoutine:
If Err.Number = 2501 Then
Msg = "Yada Yada 1 " & vbCrLf & _
"Yada Yada 2" & vbCrLf & vbcrlf & _
"Yada Yada 3"
Style = vbYesNo + vbDefaultButton1
Title = "Please Send"
Response = MsgBox(Msg, Style, Title)
If Response = vbNo Then
GoTo AddAgain:
Else
GoTo SendIt:
End If
Else
MsgBox "Error number: " & Err.Number & vbCrLf & vbCrLf & _
Err.Description, vbCritical, "Error"
End If

Resume RoutineExit
...
************** Code Snippet End *******************************


Don't use GoTo in the err handler. Use Resume instead

You appear to be missing the Exit Sub after RoutineExit:
and you need some code after GoTo AddAgain:

Bexause you are resuming to different places, move the
Resume RoutineExit up inside the Else block.
 
G

Guest

Marsh,

Thanks a bunch!! That was all I needed! I don't play so much with
the error routines and it as making me nuts. After reading and implementing
your answer I have a better understanding of it.

Vanya
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top