Generating Emails of Selected records in a continuos subform.

eddyc

Registered User.
Local time
Today, 23:42
Joined
Mar 23, 2011
Messages
43
Right!!

I am trying to send an email to all the records i have selected from a continuous form ... my code at the moment is not even start due to activex or ole problems (not sure what it means ) but can anyone look at the code i haev written and tell me why or whether it is any good .. i thikn it should work but cant run due to active x or ole prob that is a mystery to me!

Code:
Private Sub Email_Job_Details_Click()

On Error GoTo Err_Email_Job_Details_Click

'Set Focus to correct form and Goto First Record
Me.Form_Perm_Jobs.Put_Forward.SetFocus
DoCmd.GoToRecord , , acFirst

Do
    Select Case Me!Selected.Value
        Case True
            DoCmd.SendObject acSendNoObject, , , Forms![Perm Jobs]![Put Forward].Form.Email, , , "Re:" & Forms![Perm Jobs].[Job Title], "Dear " & Me.Title & " " & Me.Last_Name & ",", , False
            
            'Leave loop if that was the last record.
            If CurrentRecord = RecordsetClone.RecordCount Then Exit Do Else DoCmd.GoToRecord , , acNext
        
        Case False
            DoCmd.GoToRecord , , acNext

Loop Until CurrentRecord = RecordsetClone.RecordCount And Me!Selectd.Value = False

End Sub

Err_Email_Job_Details_Click:
    MsgBox Err.Description
    Resume Exit_Email_Job_Details_Click
End Sub

Thanks ed
 
I have changed my code but i cannot see why it is not working. it is Just saying "A problem occurred while MS ACCESS was communicating with the OLE Server or Active V control!"
Does this mean it can't find the control on the form i am trying to access ?
Code:
Private Sub Email_JobDetails_Click()
On Error GoTo Err_Email_JobDetails_Click

'Set Focus to correct form and Goto First Record
Me.Form![Perm Jobs].Job_Applicant.SetFocus
DoCmd.GoToRecord , , acFirst

Do
    Select Case Me.Selected.Value
        Case 0
            'Check email if ok send and set selected to no and [Sent] to "Sent" otherwise don't send, goto next record and keep value of selected as yes or maybe set value of [Sent] Unbound text field to "unsent"
            DoCmd.SendObject acSendNoObject, , , Forms![Perm Jobs]![Job Applicant].Form.Email, , , "A Job Opportunity! ", "Dear " & Me.Title & " " & Me.Last_Name & "," & vbLf & " We are writing to you to let you know of a Job opportunity that might interest. If it does please ring me as soon as you can." & vbLf & "Job Title: " & Form![Perm Jobs].[Job Title] & vbLf & vbLf & "Job Description: " & Forms![Perm Jobs].[Job Description], , False
            
            'Leave loop if that was the last record.
            If CurrentRecord = RecordsetClone.RecordCount Then Exit Do
            Else
                DoCmd.GoToRecord , , acNext
            End If
        Case -1
            DoCmd.GoToRecord , , acNext
    End Select
    
Loop Until CurrentRecord = RecordsetClone.RecordCount And Me!Selectd.Value = False

Err_Email_JobDetails_Click:
 MsgBox Err.Description
  Resume Exit_Email_JobDetails_Click
Exit_Email_JobDetails_Click:

End Sub
 

Users who are viewing this thread

Back
Top Bottom