G
Guest
I have a form with 20 text boxes and their associated labels. They are
labeled Field1, Field2, ... and lblField1, lblField2,...
At the top of the form I have a combo box with the numbers from 1-20. I
would like to use the visible property of the labels and text boxes in order
to make visible the range that the user picks. I.E. if 3 is selected, then
Field1, Field2 and Field3 would be visible along with their association
labels, while the other ones would not be visible. I entered the following
code in the after update event of the combo box:
Private Sub cmbNumber_AfterUpdate()
Dim Number As Integer
Number = cmbNumber
For x = 1 To Number
Me.lblFieldx.Visible = True
Me.Fieldx.Visible = True
Next x
For x = (Number + 1) To 20
Me.lblFieldx.Visible = False
Me.Fieldx.Visible = False
Next x
End Sub
However, when I try to run the code I get an "invalid method or data member"
error. The problem is obviously my attempt to create a reference to a
control using a variable. Any light that could be shed on this subject would
be appreciated.
labeled Field1, Field2, ... and lblField1, lblField2,...
At the top of the form I have a combo box with the numbers from 1-20. I
would like to use the visible property of the labels and text boxes in order
to make visible the range that the user picks. I.E. if 3 is selected, then
Field1, Field2 and Field3 would be visible along with their association
labels, while the other ones would not be visible. I entered the following
code in the after update event of the combo box:
Private Sub cmbNumber_AfterUpdate()
Dim Number As Integer
Number = cmbNumber
For x = 1 To Number
Me.lblFieldx.Visible = True
Me.Fieldx.Visible = True
Next x
For x = (Number + 1) To 20
Me.lblFieldx.Visible = False
Me.Fieldx.Visible = False
Next x
End Sub
However, when I try to run the code I get an "invalid method or data member"
error. The problem is obviously my attempt to create a reference to a
control using a variable. Any light that could be shed on this subject would
be appreciated.