grouping text boxes, memo, etc

icemonster

Registered User.
Local time
Today, 16:33
Joined
Jan 30, 2010
Messages
502
can you group a text box, a combo box etc? if so how? i tried but it only works with buttons on me for some reason. cause i have like 10 text boxes and 2 memo fields and i really am not into the whole idea of writing them individually to enable or lock. thanks for any assistance!
 
No you can't group them. But you can put something in their tag property so that you can iterate through the controls with code to do something. So, let's say you put GroupA in the Tag property of those controls. Then you can use something like this:
Code:
Dim ctl As Control
 
For Each ctl In Me.Controls
   If ctl.Tag = "GroupA" Then
      ctl.Enabled = False
   End If
Next
and you could create a generic function:
Code:
Function DisableEnable(strFormName As String, strTagValue As String, blnTF As Boolean)
Dim ctl As Control
 
For Each ctl In Forms(strFormName).Controls
    If ctl.Tag = strTagValue Then
       ctl.Enabled = blnTF
   End If
Next
End Function

And you would call it like

Call DisableEnable(Me.Name, "GroupA", False)

And that would disable them all for those with that tag.
 
but how bout just saying that you want to call all tags? let's say, by default, the text boxes combo box etc are disabled and locked, would it be possible to write something like:

Private Sub cmdEdit_Click()

Me.Tag = "GroupA"
Enabled = true
Locked = false

this is just a sample. is it possible to do something like this?
 

Users who are viewing this thread

Back
Top Bottom