[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Access looping through a listbox and grabbing values

Posted on 2008-01-31
4
Medium Priority
?
737 Views
Last Modified: 2013-11-28
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.
0
Comment
Question by:Neil2526
  • 2
  • 2
4 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 20788361
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
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 20788374
sorry, cont..
emaillist=left(emailList,len(emaillist)-1)
0
 

Author Comment

by:Neil2526
ID: 20788414
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
 

Author Comment

by:Neil2526
ID: 20788427
nevermind. i got it!

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

thanks!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question