Access looping through a listbox and grabbing values

I have a list box that has a list of emails. I want to loop through the values and make a list to shoot off emails.

Surprisingly I haven't really found anything on google that would help me do this.


emailNumber = Me.List0.ListCount


For i = 0 To emailNumber - 1
 emailList = Me.List0.ItemData & "; " & emailList
Next i

Thank you.
Neil2526Asked:
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.

Rey Obrero (Capricorn1)Commented:
dim j,emailList
with Me.List0
      if .itemsselected.count>0 then
          emailList=emailList & chr(39) & .itemdata(j) & chr(39) & ","
      end if
end with

or

with Me.List0
      if .itemsselected.count>0 then
          emailList=emailList &  .itemdata(j) & ","
      end if
end with
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
Rey Obrero (Capricorn1)Commented:
sorry, cont..
emaillist=left(emailList,len(emaillist)-1)
0
Neil2526Author Commented:
Thank you for the response capricorn.

I partly used your code, and did this:

For i = 0 To emailNumber - 1
 With Me.List0
      If .ItemsSelected.Count > 0 Then
          emailList = emailList & .ItemData(j) & ";"
      End If
 End With
Next i

But when looping, it seems to only grab my first item in the list. So emailList looks like:

ed@ed.com;ed@ed.com;ed@ed.com

thanks.
0
Neil2526Author Commented:
nevermind. i got it!

i needed to use 'i' instead of 'j'

thanks!
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.