Link to home
Start Free TrialLog in
Avatar of martin148
martin148

asked on

Referencing List Box names with Variables

I have a form with 10 listboxes, lstDetails1...lstDetails10. I would like to fill each one with different dynamic data.

I could write 10 procedures to

1. open a database
2. select records
3. loop through and fill the list boxes

I would like to write a function and pass parameters including the listbox name to be filled along with the sql statement to get the data.

The sql part is easy but I cannot figure how to refernce a listbox from a variable.

this is what I want to do

function filllistbox(listboxname, sqlstring)

loop
listboxname.additem "abcdef etc."
end loop

"listboxname" is a variable containing the name of the listbox.

Any ideas?

Thanks
Avatar of abaldwin
abaldwin

'A modular variable
dim ListBoxName as control

In the procedure you are calling the function from.
Set ListBoxName = lstDetails(1)

Now call your procedure to fill the listbox passing ListBoxName and the Sql Statement
ASKER CERTIFIED SOLUTION
Avatar of anthonyc
anthonyc

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