Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 354
  • Last Modified:

recordsetclone to loop through and send email

I am trying to send emails to recipients in a subform using its recordset. The code below is a quick draft and I'm not sure what's going wrong...it seems to spin its wheels, then crash.

Any ideas?

Dim strEmail As String
Dim strMailSubject As String
Dim strMSG As String

strMailSubject = "New translation"
strMSG = Me.tmpTranslatorMessage & _
vbCrLf & vbCrLf & Forms![frmtrad_commandes2].UserName & vbNullString

Dim db As Database
Dim rst As Recordset

Set db = CurrentDb
Set rst = [sbfrmTranslationPreselectTranslators].Form.RecordsetClone

With rst
    Do Until .EOF
        If rst("PreSelectionStatusID") = 1 Then
        strEmail = strEmail & rst("email") & ";"
        End If
End With

strEmail = Left(strEmail, Len(strEmail) - 2)
DoCmd.SendObject to:=strEmail, Subject:=strMailSubject, MessageText:=strMSG

Open in new window

  • 2
  • 2
1 Solution
Switch line 19 and 20 in above code

        End If
ShawnAuthor Commented:
oops, got it.

the button works now the first time you click on it but doesn't if you click on it again. I think I'm missiing something to reset the recordset every time the button is clicked.
ShawnAuthor Commented:

 .MoveFirst          'move to the first record

works now. thanks again

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now