For...Next: Help cycling through controls

NeuronRider

Registered User.
Local time
Today, 12:05
Joined
Mar 8, 2005
Messages
14
Aright folks, clearly I must just be doing something stupid. I can't see why this is happening. Please help point out my idiocy ;)
Here's the code:

Code:
    x = RandomNumbers(intHowMany, , intHowMany)
    q = 1
    For n = LBound(x) To UBound(x)
        Select Case strCapValue
            Case "Summer Picture"
                frmSubName.Controls("cmb_h_QID" & q) = x(n)
                frmSubName.Controls("txt_h_RandNum" & q) = q
                MsgBox "q = " & q & ", x(n) = " & x(n), vbOKCancel
            Case "Winter Picture"
                frmSubName.Controls("cmb_h_QID" & q) = x(n)
                frmSubName.Controls("txt_h_RandNum" & q) = q
                MsgBox "q = " & q & ", x(n) = " & x(n), vbOKCancel
        End Select
        q = q + 1
    Next n

Quick annotations: RandomNumbers is another function, returning an array of random, unique values. intHowMany is defined prior to this and seems to working just fine. frmSubName is a form object name passed to this function, with 2 possible caption values, thus the select cases. The combo control is tied to a relationship that pulls a specific question, while the RandNum is actually the order that these questions are asked in each time. i.e. Question 16 from tbl_QuestionTable1 was asked as question q during session#.

Specifics aside, here's the issue. of the 12 different tabs each containing their own set of the two controls (all one form, no subs here), they all get the same value. txt_h_RandomNum* is always 12, while cmb_h_QID* is always x(11), that is to say the value of the array when q = 12. All of them.

The MsgBox stuff was just to help me convince myself that all the values are actually working. I get 12 sequential MsgBoxes for q = 1 to 12, with the resulting unique x(n). So the values are really there. :D

What am I doing wrong here? Why do all the controls end up with the same value?

Thanks,

-NR
 
Last edited:

Users who are viewing this thread

Back
Top Bottom