Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Access

Concatenate Email Addresses

 
Jump to:  
 
SoDakRah
PostPosted: Wed Sep 03, 2008 7:59 pm    Post subject: Concatenate Email Addresses
       
I want to read a table of users and concatenate their email addresses into
one long string to address one email instead of individual emails.

Example table A has 10 employees, 2 departments D1, D2

I use a query to open a recordset RST and read through the table extracting
each email for a selected department. strTo = RST.email
Now I want to append the next users email address to the first one.
Something like
strTo = strTo & "," & RST.email

This does not work.

Any help will be appreciated.
 

 
pietlinden@hotmail.com
PostPosted: Wed Sep 03, 2008 10:15 pm    Post subject: Re: Concatenate Email Addresses
       
On Sep 3, 4:59 pm, SoDakRah <SoDak...@discussions.microsoft.com>
wrote:
Quote:
I want to read a table of users and concatenate their email addresses into
one long string to address one email instead of individual emails.

Example table A has 10 employees, 2 departments D1, D2

I use a query to open a recordset RST and read through the table extracting
each email for a selected department.  strTo = RST.email
Now I want to append the next users email address to the first one.  
Something like
strTo = strTo & "," & RST.email

This does not work.

Any help will be appreciated.

It doesn't work because you're not looping anywhere...

dim rs as dao.recordset
set rs=CurrentDB.Querydefs("YourQueryDef").OpenRecordset
do until rs.EOF
strTo = strTo & "," &rs.Fields("EMail")
rs.MoveNext
Loop
strTo=right$(strTo,len(strTo)-1)
 

 
SoDakRah
PostPosted: Thu Sep 04, 2008 2:36 pm    Post subject: Re: Concatenate Email Addresses
       
Sorry, I did have a do...loop in the code but did not include that
information. I was getting an error (Object Required) on the strTo=strTo
line and thought it has something to do with setting a string equal to
itself. Your message made me look very close at my code and I found a
mispelled field name. Is my face red! I corrected that and the loop works
perfectly. Thanks for your assistance.

"pietlinden@hotmail.com" wrote:

Quote:
On Sep 3, 4:59 pm, SoDakRah <SoDak...@discussions.microsoft.com
wrote:
I want to read a table of users and concatenate their email addresses into
one long string to address one email instead of individual emails.

Example table A has 10 employees, 2 departments D1, D2

I use a query to open a recordset RST and read through the table extracting
each email for a selected department. strTo = RST.email
Now I want to append the next users email address to the first one.
Something like
strTo = strTo & "," & RST.email

This does not work.

Any help will be appreciated.

It doesn't work because you're not looping anywhere...

dim rs as dao.recordset
set rs=CurrentDB.Querydefs("YourQueryDef").OpenRecordset
do until rs.EOF
strTo = strTo & "," &rs.Fields("EMail")
rs.MoveNext
Loop
strTo=right$(strTo,len(strTo)-1)
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

Kawały Mieszkania Kraków kwatery zakopane walczak projektowanie stron internetowych