Question

I'm trying to pull email addresses from a table and format them into a string that can be used in the "TO:" field of an outlook message. For some reason, the loop that i wrote is freezing the program. Can anyone spot what I'm doing wrong or offer a better way to do this? here is the code i have at the moment:

Private Function GetMailingList() As String

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim results As String

    results = ""
    Set db = CurrentDb
    Set rs = db.OpenRecordset("lut_holdEmailList")

        Do Until rs.EOF
            results = results & rs.Fields("emailAddress") & ", "

        Loop

    GetMailingList = results

End Function
Was it helpful?

Solution

You missed the MoveNext call:

add this line to the Do Untill Loop

rs.MoveNext()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top