Cleaner way to disable multiple controls? (1 Viewer)

ejstefl

Registered User.
Local time
Today, 06:50
Joined
Jan 28, 2002
Messages
378
Hello,

I need to disable certain contols on a form. I am looking for a cleaner way to do it than I am. I do not want to disable all controls. Below is what I have now. What I'm wondering is if there is some way maybe to assign each of the controls to an array, and then loop through the array? Any help is appreciated.

Code:
    With Me
        
        With .txtTrustAcctNumber
            .Enabled = True
            .Locked = False
            .BackStyle = 1
        End With
        
        With .cboTrustDatabaseID
            .Enabled = True
            .Locked = False
            .BackStyle = 1
        End With
        
        With .txtControlID
            .Enabled = True
            .Locked = False
            .BackStyle = 1
        End With
        
        With .txtTrustAcctName
            .Enabled = True
            .Locked = False
            .BackStyle = 1
        End With
    End With
 
R

Rich

Guest
Something like
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "A" Then
If IsNull(Me.pd) Then
End If
If Me.pd = True Then
ctl.Locked = True
ctl.Enabled = False
Else
ctl.Enabled = True
ctl.Locked = False
End If
End If


Next

End Sub
 

ejstefl

Registered User.
Local time
Today, 06:50
Joined
Jan 28, 2002
Messages
378
OK, So I would need to assign a tag to each control that I want affected. Brilliant! The one part I don't understand... what is Me.pd?
 

ghudson

Registered User.
Local time
Today, 01:50
Joined
Jun 8, 2002
Messages
6,195
pd would have to be a field [check box?] that he is checking if the value of pd is Null or True.
 

Users who are viewing this thread

Top Bottom