Adding records to a temporary variable.

  • Thread starter Thread starter reidarT
  • Start date Start date
R

reidarT

I have a table with records (emailaddresses).
I want to add theese addresses to a variable delimited with a semicolon.
How do I do that?
reidarT
 
How many addresses do you have?
What is the purpose of this, it doesn't really seem to me to be a good idea;
however, you can establish the table as a recordset, and read through it
adding each address and a semicolon to the string. Then, you will need to
remove the last semicolon when you are done. It goes like this:

Function CreateReallyLongString() as String
Dim rst As DAO.Recordset
Dim dbf As DAO.Database
Dim strAddresses As String

Set dbf = Currentdb
Set rst = dbf.OpenRecordset("MyTableNameHere")

With rst
If .RecordCount > 0 Then
.MoveLast
.MoveFirst
End If

Do While Not .EOF
strAddresses = strAddresses & ![EmailAddress] & ";"
.MoveNext
Loop
.Close
End With

Set rst = Nothing
Set dbf = Nothing

CreateReallyLongString = Left(strAddresses, Len(strAddresses) - 1)

End Function
 
Back
Top