try this.
Just copy this into a module. You'll need to add your error checking.
Look at the test sub to see how to use it.
Rodrigo
sub Test()
dim strEmails as string
strEmails = ParseQryResults("qryEmails","EmailAddress")
msgbox strEmails
end sub
Public function ParseQryResults(QryName_or_SQL_or_TableName as string,
FieldName as string) as string
On error resume next
dim db as dao.database
dim rst as dao.recordset
dim strTmp as string
' Open a recordset with your table/query/sql and make sure it has records
set db = dbengine(0)(0)
set rst = db.openrecordset(QryName_or_SQL_or_TableName)
if (rst.eof and rst.bof) then
exit function
end if
' loop trough the values on the field you want adding them to a
temporary string and adding a comma
while not rst.eof
strtmp = strtmp & rst(fieldname).value & ", "
rst.movenext
wend
set rst = nothing
set db = nothing
' take out the comma and space and return the value of the temporary string
ParseQryResults = left(strtmp,len(strtmp)-2)
end function