Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi Select List box to fill array and then run sql from that array 1

Status
Not open for further replies.

sna1maa14

Programmer
Nov 21, 2003
23
US
I have a Multi-select (simple) list box with customer account Names (unbound) and IDs (bound). I want to be able to select the customers I need and then print their reports. So what I need to do is get the list of customers, loop through their Id's, run a sql select based off the first name and print report then go to the next and so forth until I reach the end. I have never used arrays and can't seem to grasp how to create one on the fly and then loop through it. I'm going home now but will check back tomorrow for any post. I do have a basic knowledge of VBA.

Thank you for any help or code you provide.
sna1maa
 
Have a look at ItemsSelected in the VBA help.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
How are ya sna1maa14 . . . . .

What [blue]data[/blue] are you getting from the [blue]SQL[/blue], or is it the [blue]RecordSource[/blue] of the report.

You don't need arrays. You can enumerate the ItemsSelected Collection. Example:
Code:
[blue]   For Each itm In Me!ListboxName.[purple]ItemsSelected[/purple]
      Variable = Me!ListboxName.Column(n, itm)
      [green]'other code[/green]
   Next[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks aceman i will give it a try. i'm using the sql to create a table with the customers info for the report. Basicaly create a table then output ot excel. Unforunatley I'm out of work now for a week , I spraied my ankle. I will try it at home with a test db.
 
Thanks Aceman that works perfect. I just tried it out and it does exacly what i need to. Why is it that the smallest of code is sometimes the hardest to figure out. Well at least for newbies like me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top