I have a form that contains twenty controls for # of hours, Sum of hours, and
hours_label. (example: A1_Hours, A2_Hours....,A20_Hours and A1_HoursSum,
A2_HoursSum....,A20HoursSum and
A1_Hours_Label,A2_Hours_Label....A20_Hours_Label )
I have created a private sub that loops through a datasource that contains
up to 20 label captions. Based upon the number of captions (x) I would like
to set the associated control properies:
Example:
x=1
Do While Not rs.EOF 'Loop through all records in dataset
'Read in initial AC_CATEGORY_NAME
Act_Cat = rs(1)
'Set field label, and visability parameters
BHE_Ax_HOURS.Visible = True
BHE_Ax_Sum.Visible = True
BHE_Ax_HOURS_Label.Visible = True
BHE_Ax_HOURS_Label.Caption = Acct_cat
'Increment counter and Step to next record
x = x + 1
rs.MoveNext
Loop
How do I dynamically name the control? I tried "BHE_A"&x&"_HOURS" but this
does not work
George Nicholson - 20 Jun 2007 20:23 GMT
ohhhhh, soooo close:
frm.Controls("BHE_A"& x &"_HOURS")
(where frm is the Form you are working with. You could substitute Me if your
code is in that Form's module)
HTH,
>I have a form that contains twenty controls for # of hours, Sum of hours,
>and
[quoted text clipped - 26 lines]
> this
> does not work
Mymind - 21 Jun 2007 13:44 GMT
This worked well. I ended up using the Me.
Thanks for all your help.
> ohhhhh, soooo close:
>
[quoted text clipped - 35 lines]
> > this
> > does not work