在access 2010 vba中创建记录集的邮件列表?

时间:2011-09-05 23:18:40

标签: loops recordset ms-access-2010 mailing-list

我正在尝试从表中提取电子邮件地址并将其格式化为可在outlook消息的“TO:”字段中使用的字符串。出于某种原因,我写的循环是冻结程序。谁能发现我做错了什么或提供更好的方法来做到这一点?这是我目前的代码:

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

1 个答案:

答案 0 :(得分:0)

您错过了MoveNext来电:

将此行添加到Do Until循环

rs.MoveNext()