Controls for textboxes on userforms


Posted by Anna Daly on November 20, 2000 1:43 AM

Hi,

I have a problem with controls for textboxes on userforms. The following code shows what I am trying to do, the code works fine but I need it to work for all textboxes on all my userforms. At the moment it only works for textboxes on the "PlantHire" userform. Is there a way of making the following code adaptable for all userforms? I have tried everything I can think of but havn't managed to get any thing to work. The only method that I can think of is re-writting the code for each individual userform. Since I have about 15 userforms this dosn't seem very a efficient or sensible method. Any suggestions would be kindly received.

Here is that code:

Sub DISABLE (firstlabel, lastlabel, bool)
Dim no as Integer
Dim Noentry as Object
Dim Labelname as String

For no = firstlabel To lastlabel
Labelname = "Input" & no
Set Noentry =PlantHire.Controls.Item(Labelname)
Noentry.Enabled = Bool
Next
End Sub


kind regards

Anna



Posted by Tim Francis-Wright on November 21, 2000 11:06 AM

I would think that you could change
Sub DISABLE (firstlabel, lastlabel, bool)
to
Sub DISABLE (Whichform, firstlabel, lastlabel, bool)

and
to

You would need to specify the userform in question
when you called the subroutine--but that shouldn't
pose too tought a problem.

HTH