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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Powerpoint 2010 VBA how refer to a combox box on a form using a variable 1

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
How can I refer to a Combo box using a variable?
I have a subroutine that I pass a managers name to and it figures out using SQL who is under them to draw an Org chart.
I have 4 combo boxes called cboReport1, cboReport4, cboReport4, cboReport4
As you drill down to each box it shows the people that report "To" the one above them in a hierarchy manner.

So I need to not only get the List count for any particular combox box but also get the items in it.

I would rather not use a Select case with 4 items to determine which one I need a lot of extra code.

My "ReportTo" variable will contain the words “Report1” or “Report2” etc depending whihc one is being used at the time.

I tried this from another site but it’s no good in Powerpoint VBA.
for b = 0 to Me.(ReportTo).ListCount – 1

Code:
For b = 0 To Me.cboReport3.ListCount – 1
	If Me.cboReport3.List(b) <> rst!Name Then  < I need to get these values for any of the 4 combo boxes when I come in here

Next
----

This is what I need it to look like somehow
Code:
For b = 0 To Me.”ReportTo”.ListCount – 1
	If Me. ”ReportTo”(b) <> rst!Name


DougP
 
So you have 1 combo named cboReport1 and 3 combos named cboReport4?
Probably not.

If you have cboReport1, cboReport2, cboReport3, and cboReport4, you may be able to lo thru them like this:
Code:
Dim i As Integer

For i = 1 to 4
    Me.Controls("cboReport" & i)
Next i


Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top