Stuck: Searching Controls for a specific control name and changing the control value (1 Viewer)

YevS

Registered User.
Local time
Today, 23:19
Joined
May 23, 2007
Messages
39
Hi,

Ive been trying to get a piece of code out that dynamicaly looks at several controls at a certain "level" and sets the controls on the "levels" below to a value that the user has chosen on the first level... I'll try to explain:

The user has 8 levels of data, the first level choise determines the data on all the other levels. Its a tree structure.

I have a combo box and 2 text boxes ( can be labels if that makes adifference) for each level. The combo box gets data for the user to pick and the text boxes display additional info.The structure goes like this:

Combo1 : Description1 ; ResponsiblePerson1
Combo2 : Description2 ; ResponsiblePerson2
Combo3 : Description3 ; ResponsiblePerson3
Combo4 : Description4 ; ResponsiblePerson4


The simplified code im using is this:

Code:
Private Function UpdateNextLevel(CL As Integer)
 
Dim ComboCtrl As Control
Dim DescCtrl As Control
Dim RespPCtrl As Control
 
Dim SQL As String
 
For NL = CL To 8
    For Each ComboCtrl In Me.Controls
        If ComboCtrl.Name = "Combo" & NL Then
 
            'build SQL for next combo <cut out>
            'seting up the next level rowsource 
            ComboCtrl.RowSource = SQL
            nl = nl +1
 
        end if
    next
next

My question is, is there any elegant way to also find/set the text/label boxes to say combo1.column(2)??

I seem to have to do it in that if statement, but if i do that will I have to loop through all the controls again? Can I look/find all 3 controls at the same time? Or at least set them as variables for the levels loop?
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 23:19
Joined
Sep 12, 2006
Messages
15,738
not sure exactly what you are doing, but I (may) do something similar with a hierarchical nominal ledger.

I use a table to store the appropriate level descriptions - so if you are in level 3, look up the description for level 3. etc
 

YevS

Registered User.
Local time
Today, 23:19
Joined
May 23, 2007
Messages
39
The issue is not the storage or the retrieval of the data, its finding the controls to put the data in...

I cant figure out how to grab a control and set its value without having to pass the control name via another event. I'm trying to set values for 8 x 3 controls in 1 event with a loop.

I can set up values for the combo boxes 1 to 8, but when it comes to descriptions in another box I have to loop through again AND get data from the combo boxes I just set up.

I'm just not sure whats the best way to do that, maybe some way to search for 3 controls at the same time?
 

Users who are viewing this thread

Top Bottom