Link to home
Start Free TrialLog in
Avatar of Neil2526
Neil2526

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry, cont..
emaillist=left(emailList,len(emaillist)-1)
Avatar of Neil2526
Neil2526

ASKER

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.
nevermind. i got it!

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

thanks!