I'm just getting started with Access and vba and any help would be greatly appreciated.
I am trying to create a string of email addresses from a query called 'Clients' and the field name is 'email'.
I found the code below and however the result is a string of numbers instead of the actual email address in the field.
The result is "213;324;656;222;435;432"
I would like it to return "johndoe@gmail.com;janedoe@gmail.com...."
Here is the code below.
Expand|Select|Wrap|Line Numbers
- Dim MyDB As DAO.Database
- Dim rstEAddr As DAO.Recordset
- Dim strBuild As String
- Set MyDB = CurrentDb
- Set rstEAddr = MyDB.OpenRecordset("Clients", dbOpenForwardOnly)
- With rstEAddr
- Do While Not .EOF
- If ![email] <> "" Then
- strBuild = strBuild & ![email] & ";"
- End If
- .MoveNext
- Loop
- End With
- rstEAddr.Close
- Set rstEAddr = Nothing
- fConcatEMailAddr = Left$(strBuild, Len(strBuild) - 1)