comma separated list in text box

rwilliams

Registered User.
Local time
Today, 13:38
Joined
Jun 5, 2007
Messages
20
I'm not even sure what to call this problem...

I have a form, that I've set up to do an email function. There are text boxes for [To:], [Subject:], [Body], and [Attachment:]. I am running a query that pulls names, emails, and dates pertaining to vaccinations. The query shows who's vaccinations expire during a user entered date range.

I would like the To: field on my email form to automatically populate (when the form is opened) with the emails from the query. For example, the emails need to be in a comma separated list for mass emailing... name@domain.com, name@domain.com, name@domain.com, etc...

I'm not sure what to put in the control source for the [To:] text box so that it will pull the email once from all returned records from the query.

Any ideas?
 
rw,

You'll need to create a recordset and traverse it with VBA code
to do this.

There's a MS article about this, but I don't have the link.

Code:
Dim rst As DAO.Recordset
Dim strTemp As String

strTemp = ""

Set rst = CurrentDb.OpenRecordSet("Select * From Your Table Where ...")

While Not rst.EOF and Not rst.BOF
   strTemp = strTemp & rst!SomeName & ","
   rst.MoveNext
   Wend
strTemp = Left(Len(strTemp) - 1) '<-- remove trailing ","

Wayne
 

Users who are viewing this thread

Back
Top Bottom