D
Derek Dowle
UserForm Query
I have a User Form which is used to collect monthly cost information for a
five year period for a database. The start month and year of the five year
period will vary from record to record.
Intially the user enters the start month and start year into separate Text
Boxes. From this information I have created an Array, strMonthLabels(60),
which contains each month and year for the five year period; i.e. "Jan 2009",
"Feb 2009", etc.
Each of the Text Boxes to capture the month cost information has an adjacent
Label to signify the month and year so that the user can enter the data
correctly. These Labels are named lblMonth1 through to lblMonth60.
I want to be able to use a For-Next Loop to change the Captions on each of
the Labels. The following indicates my intententions but does not work.
For i = 1 To 60
lblMonth(i).Caption = strMonthLabels(i)
Next
An alternative I have tried unsuccessfully is to create a Label variable
Dim objLabelName As Label
and then a value for this variable
objLabelName = "lblMonth" + Trim(Str(i))
objLabelName.Caption = strMonthLabels(i)
The answer is probably staring me in the face!
Please can you advise how to use a For-Next Loop to move from Label to Lable
to change each caption?
Many thanks
I have a User Form which is used to collect monthly cost information for a
five year period for a database. The start month and year of the five year
period will vary from record to record.
Intially the user enters the start month and start year into separate Text
Boxes. From this information I have created an Array, strMonthLabels(60),
which contains each month and year for the five year period; i.e. "Jan 2009",
"Feb 2009", etc.
Each of the Text Boxes to capture the month cost information has an adjacent
Label to signify the month and year so that the user can enter the data
correctly. These Labels are named lblMonth1 through to lblMonth60.
I want to be able to use a For-Next Loop to change the Captions on each of
the Labels. The following indicates my intententions but does not work.
For i = 1 To 60
lblMonth(i).Caption = strMonthLabels(i)
Next
An alternative I have tried unsuccessfully is to create a Label variable
Dim objLabelName As Label
and then a value for this variable
objLabelName = "lblMonth" + Trim(Str(i))
objLabelName.Caption = strMonthLabels(i)
The answer is probably staring me in the face!
Please can you advise how to use a For-Next Loop to move from Label to Lable
to change each caption?
Many thanks