email addresses

Sebastian

New member
Local time
Today, 21:08
Joined
Jun 12, 2006
Messages
5
Simple query from an amateur. I have a list of people in a table, each with thier email address. How can I convert this into a list of addresses to paste into a group email? (Ideally with ";" as a separator between addresses)
 
Paste the below function into a Module and you will be able to use it to retrieve a list of email addresses seperated by a ;.


PHP:
Public Function EmailAddress(Query As String, AddressField As String) As String

    Dim strQry, strAddField, strAddress As String
    Dim recEmail As DAO.Recordset
    
    Set recEmail = CurrentDb.OpenRecordset(strQry)
    
    recEmail.MoveFirst
    
    Do Until recEmail.EOF
        If IsNull(strAddress) = True Then
            strAddress = recEmail.Fields(strAddField) & ";"
        Else
            strAddress = strAddress & recEmail.Fields(strAddField) & ";"
        End If
    Loop
    
    EmailAddress = strAddress
    
End Function
 
More help needed I fear

KeithG said:
Paste the below function into a Module and you will be able to use it to retrieve a list of email addresses seperated by a ;.

Thank you for your very helpful reply, but I am afraid that I do not know how to use modules - could you explain to me how to get a module to print out the lsit of email addresses.

Sebastian
 
Hi Keith G

Are you able to help with this piece of code - I have tried to put it behind a form and called it without success and I also put it in a module an called it from a form. Not quite sure what I am suppose to do.

Many thanks
Tee
 
Try this

PHP:
Public Function EmailAddress(Query As String, AddressField As String) As String 

    Dim strQry, strAddField, strAddress As String 
    Dim recEmail As DAO.Recordset 
     
    Set recEmail = CurrentDb.OpenRecordset(strQry) 
     
    recEmail.MoveFirst 
     
    Do Until recEmail.EOF 
        If IsNull(strAddress) = True Then 
            strAddress = recEmail.Fields(strAddField) & ";" 
        Else 
            strAddress = strAddress & recEmail.Fields(strAddField) & ";" 
        End If 
        recEmail.movenext
    Loop 
     
    recEmail.close
    EmailAddress = strAddress 
     
End Function
 

Users who are viewing this thread

Back
Top Bottom