padrepio2
asked on
DAO Recordset Loop
Hi
I'm attempting to loop through the values in a query (qryEmailRecipients) to establish if the value of a Yes/No field (Damage) is true. If it is, then get the value of the 'emailaddress' field value. Seems OK if all values of the Damage field are True but if one record has a False value, the code (I suspect) simply keeps looping. Should I be testing for null?
I'm attempting to loop through the values in a query (qryEmailRecipients) to establish if the value of a Yes/No field (Damage) is true. If it is, then get the value of the 'emailaddress' field value. Seems OK if all values of the Damage field are True but if one record has a False value, the code (I suspect) simply keeps looping. Should I be testing for null?
Set db = CurrentDb
Set rs = db.OpenRecordset("qryEmailRecipients")
Do While Not rs.EOF
If rs!damage = True Then
strListEmail = strListEmail & ";" & rs!emailaddress
rs.MoveNext
Else
End If
Loop
strListEmail = Mid(strListEmail, 2)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Brilliant, thank you
-it is because the rs.MoveNext at line 8 is at the wrong location
- move the rs.MoveNext after End If before Loop