help with VBA code error

G

Guest

i hope someone can help me with the code below, i am new to access and very
new at vba code but see it as a nessesary evil to do what i need.

the code below was supposed to delete arecord but before doing the delete
ask if i would like to send an email of confirmation, all 0f this seems to
work. i.e. the email is sent and the record deleted. the problem is that i
then get a dialogue box come up that says Resume without Error with one
button OK. on pressing this i get a blank dialogue box with an ok button
press this and return to Resume without Error with one button OK ad infinitum
i have to ctrl-Alt-Del out of access

Private Sub Delete_Record_Click()
On Error GoTo Err_Delete_Record_Click

If vbYes = MsgBox("Do you want to send an email?", _
vbYesNo + vbQuestion, "Send Email?") Then
'Send the email

DoCmd.SendObject , "", "", "pmayor", "", "", "Cancellation of Cancer
Course", "Dear Colleague, Following recent communication I can confirm that
your place on the Cancer Course has been Cancelled. Thank you Phil", False,
""


Copy_of_sendemail_Exit:


End If



'Code to delete the record

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Delete_Record_Click:



Err_Delete_Record_Click:
MsgBox Err.Description
Resume Exit_Delete_Record_Click


End Sub

hope you can help

Phil
 
B

Brendan Reynolds

You need to change this ...

Exit_Delete_Record_Click:

Err_Delete_Record_Click:

.... to this ...

Exit_Delete_Record_Click:
Exit Sub

Err_Delete_Record_Click:

Without the Exit Sub, your error handling code will always run, regardless
of whether any error has occurred or not.
 
G

Guest

thanks that worked great

Phil

Brendan Reynolds said:
You need to change this ...

Exit_Delete_Record_Click:

Err_Delete_Record_Click:

.... to this ...

Exit_Delete_Record_Click:
Exit Sub

Err_Delete_Record_Click:

Without the Exit Sub, your error handling code will always run, regardless
of whether any error has occurred or not.
 

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