How populate text field with email addresses

On a form I have a combobox field and a textbox.  The combobox field is named cboCCEmployee and the textbox is named txtccEmpEmailAddresses.

The form is bound to a table and in the table are two fields...  CCemployee and ccEmpEmailAddresses.

When the user selects a record from the combobox I want the email address (3rd field in the record source query) to populate into the field txtccEmpEmailAddresses.  But when the user selects ANOTHER record in the combobox I want that email address to be added to the first email address in the text box but have a comma and a space in between the two.  If they select a 3rd record in the combobox repeat all of this.  So then the end result is something like this in the textbox:

name@company.com, anothername@company.com, thirdname@company.com.

Can this be done?
SteveL13Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale FyeCommented:
Private Sub cboCCEmployee_AfterUpdate

    dim strEmail as string

    strEmail = me.txtccEmpEmailAddresses & "," & cboCCEmployee.column(2)
    if left(strEmail,1) = "," then strEmail = mid(strEmail,2)
    me.txtccEmpEmailAddresses = strEmail

End Sub

Open in new window

0
SteveL13Author Commented:
Thanks.  Almost.  But I'm getting a comma in front of the first one clicked on.  Don't want that.  Just after the first one and every one following that.
0
Dale FyeCommented:
line 6 should strip that fist comma out.  Are you simply adding a comma, or do you have a space in there as well.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

SteveL13Author Commented:
After the first email address is populated it should add a comma and the a space before the next email address is added.
0
Dale FyeCommented:
I've modified the following so that it adds a ", " before each new email address that is added.  It then checks to see whether the first two characters are ", " and if so, strips them out.
Private Sub cboCCEmployee_AfterUpdate

    dim strEmail as string

    strEmail = me.txtccEmpEmailAddresses & ", " & cboCCEmployee.column(2)
    if left(strEmail,2) = ", " then strEmail = mid(strEmail,3)
    me.txtccEmpEmailAddresses = strEmail

End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SteveL13Author Commented:
That'll do it.  Thanks again.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.