Email Problem

Groundrush

Registered User.
Local time
Today, 05:24
Joined
Apr 14, 2002
Messages
1,376
I have a command button that when clicked on, attaches a doc to an email.

The problem is that it only works once, nothing happens when you click on it again. You have to close the database down then go back into the main form.
any ideas?

see my code below.

Private Sub cmdEmailJob_Click()
DoCmd.SendObject acReport, "rptVinciInstructionToEngageSubCon", "RichTextFormat(*.rtf)", EMail, , , SubjectLine, _
"Please see attached document.", False
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblSubConOrders SET tblSubConOrders.MailSent = -1 WHERE (((tblSubConOrders.MailSent)=0))"
DoCmd.OpenQuery "qryEmailSent", acNormal, acEdit
DoCmd.SetWarnings True
Forms!frmSubConOrders.Refresh
DoCmd.GoToControl "JobNo"
DoCmd.GoToRecord , "", acNewRec
End Sub


Cheers
 
You need something like: Resume Next:

at the end of your code..... I also use On Error Resume Next before the code in case the email gets canceld...
 
sonny said:
You need something like: Resume Next:

at the end of your code..... I also use On Error Resume Next before the code in case the email gets canceld...

Hi Sonny

Tried your suggestions and it still does not work........perhaps I am doing something wrong with the code
this is what I have so far:

Private Sub cmdEmailJob_Click()
On Error Resume Next
DoCmd.SendObject acReport, "rptVinciInstructionToEngageSubCon", "RichTextFormat(*.rtf)", EMail, , , SubjectLine, _
"Please see attached document.", False
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblSubConOrders SET tblSubConOrders.MailSent = -1 WHERE (((tblSubConOrders.MailSent)=0))"
DoCmd.OpenQuery "qryEmailSent", acNormal, acEdit
DoCmd.SetWarnings True
DoCmd.GoToControl "JobNo"
DoCmd.GoToRecord , "", acNewRec
DoCmd.Close acForm, "frmSubConOrders"
DoCmd.OpenForm "frmSubConOrders", acNormal, "", "", , acNormal
Resume Next
End Sub

the email works once only, when you try and send another the command button just refreshes the form and goes to new record.

Cheers
 

Users who are viewing this thread

Back
Top Bottom