The Archn00b
Registered User.
- Local time
- Today, 06:30
- Joined
- Jun 26, 2013
- Messages
- 76
Hi everyone. Happy New Year to you all.
I'm working on a user form that has a number of check boxes on the left. On the right hand side there are two text boxes for each check box. When a check box is ticked (set to true) the two text boxes on the right hand side become active.
Rather than write an event subroutine for each check box I came up with this subroutine:
It fails on:
For Each ctl in Form.Controls
With the Error Message:
Run time error number 13: Mismatch.
I don't understand why. I've declared ctl as a Control.
Any ideas? Thanks.
I'm working on a user form that has a number of check boxes on the left. On the right hand side there are two text boxes for each check box. When a check box is ticked (set to true) the two text boxes on the right hand side become active.
Rather than write an event subroutine for each check box I came up with this subroutine:
Code:
Dim ctl As Control
For Each ctl in Form.Controls
If ctl.Tag = checkbox.Tag And ctl.ControlType = acTextBox Then
Select Case checkbox.Value
Case True
ctl.Enabled = True
ctl.BackColor = &H80000009
Case False
ctl.Enabled = False
ctl.BackColor = &H8000000E
End Select
End If
Next ctl
It fails on:
For Each ctl in Form.Controls
With the Error Message:
Run time error number 13: Mismatch.
I don't understand why. I've declared ctl as a Control.
Any ideas? Thanks.