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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

do while not, loop

Status
Not open for further replies.

moogie

MIS
May 31, 2001
10
0
0
AU
Using a small loop to send e-mail to a mailing list. Format is as follows.

>>>>>>>>>>>>>

Do While NOT Recordset1.EOF
mailBody = GP_GenerateMailBody() 'index.htm,multi,onsubmit
GP_SendHtmlMail "sales@genecon.com.au",Recordset1.Fields.Item("Email").Value,"","E-mail Subject Here"," Recordset1.MoveNext
Loop

>>>>>>>>>>>>

For some reason, this loop will ONLY send the FIRST record in the database, then gives up.

Anyone have any idea why?

Matthew
 
Are you sure your recordset is returning more than one record?

I don't know why the Do While NOT isn't working, but you could use While NOT ... WEND instead. That should work.

While NOT Recordset1.EOF
mailBody = GP_GenerateMailBody() 'index.htm,multi,onsubmit
GP_SendHtmlMail "sales@genecon.com.au",Recordset1.Fields.Item("Email").Value,"","E-mail Subject Here"," Recordset1.MoveNext
WEND
 
If you are ordering in your SQL statement, then it returns the recordset with the rs pointer pointing to whatever used to be the first record. Try doing a Recordset1.MoveFirst before you enter your loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top