Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<b>looping through a recordset<b/>

Status
Not open for further replies.

Richey

Technical User
Aug 29, 2000
121
GB
I have the following code which is opening a recordset of the field <i>email<i/>. I know there are at least 2 different email addresses in there, but it only ever sends to the first one. I presume I need to loop through the recordset somehow?

Dim db As Database
Dim rs As Recordset
Dim strsql As String

Set db = CurrentDb
strsql = &quot;SELECT DiSTINCT email from test_email&quot;
Set rs = db.OpenRecordset(strsql)
DoCmd.SendObject acSendForm, &quot;testemail&quot;, acFormatXLS, rs(&quot;email&quot;), , , , , True


regards
Tony
 
Hi!

This should do the trick;

Dim db As Database
Dim rs As Recordset
Dim strsql As String

Set db = CurrentDb
strsql = &quot;SELECT DiSTINCT email from test_email&quot;
Set rs = db.OpenRecordset(strsql)

Do While Not rs.EOF
DoCmd.SendObject acSendForm, &quot;testemail&quot;, _
acFormatXLS, rs(&quot;email&quot;), , , , , True
rs.MoveNext
Loop
rs.close
set rs=nothing

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top