Do While Function

C

Chapco Ryno

I need a simple do while loop or whatever would work best
to read all the rows in a specified column and return
them concatenated into one string separated by semicolons
like in my example below

Column in table contains an email address in each record:

(e-mail address removed)
(e-mail address removed)

need the loop to read through all records in that column
and return a string like:

"(e-mail address removed);[email protected]"......etc, so
that I can paste or use that for an Outlook To field.

Thanks in advance for any help you can lend me!!!

Chapco Ryno
 
T

Tim Ferguson

Column in table contains an email address in each record:

(e-mail address removed)
(e-mail address removed)

need the loop to read through all records in that column
and return a string like:

' this line may not be neccesary
rs.MoveFirst

' start a loop
do while not rs.EOF

' this is not the most efficient way of doing this
' but it's the clearest!
if len(strList)>0 then strList=strList & ","

' now add the current value
' null values are implicitly coerced to ""
strList = strList & rs!EmailAddress

' okay, now look at the next record
rs.MoveNext

' the loop will stop when the recordset gets to EOF
loop

Hope that helps


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top