email each individual separately

  • Thread starter Thread starter wpshop
  • Start date Start date
W

wpshop

I have a query name [qryProgressRptResearcherFinal]. The query has the
following fields: [Item#],[Fund Number],[Account Number],[Date Received],
[Researcher],. I want to push a bottom and if there is a record for a
researchers I want the information to email to the [Email] address on the
record. I have 58 researchers so I want to be able to push one button and
have a code loop until all researchers have been emailed. I know how to
write code to send an email based on variables but I have never tried a loop
before. Please let me know if you need more information.
 
Try something like this in the click event of your button

Dim db As Database
Dim rs As Recordset
Dim strEmail As String
Dim strResearcher as String

Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM [qryProgressRptResearcherFinal]")
rs.MoveFirst
While Not rs.EOF
strEmail = rs.Fields(5)
strResearcher = rs.Fields(4)
MsgBox strEmail & " - " & strResearcher
' replace the msgbox with your code to send the e-mail
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
Set db = Nothing
 
Back
Top