finaljustice
Board Regular
- Joined
- Oct 6, 2010
- Messages
- 175
Hello,
Why won't "control()" work inside a moduel which is called uppon from a click action of a button??
Basically this code works fine: (inside a module and the userform button calls this macro)
But if I tried it like so:
If I use this code above INSIDE the button code it works. Am I missing any coding?
A variable declared Public can be accessed either codes inside userform and moduels?
Thanks for your time!
Final
Why won't "control()" work inside a moduel which is called uppon from a click action of a button??
Basically this code works fine: (inside a module and the userform button calls this macro)
Code:
Sub test1()
If UserForm1.CommandButton1.Caption = "Unlock" Then
UserForm1.ComboBox2.Enabled = True
UserForm1.ComboBox3.Enabled = True
UserForm1.ComboBox4.Enabled = True
UserForm1.TextBox19.Enabled = True
UserForm1.CommandButton1.Caption = "Lock"
ElseIf UserForm1.CommandButton1.Caption = "Lock" Then
UserForm1.ComboBox2.Enabled = False
UserForm1.ComboBox3.Enabled = False
UserForm1.ComboBox4.Enabled = False
UserForm1.TextBox19.Enabled = False
UserForm1.CommandButton1.Caption = "Unlock"
End If
But if I tried it like so:
Code:
Sub test1()
If UserForm1.CommandButton1.Caption = "Unlock" Then For i = 2 To 4
Controls("ComboBox" & i).Enabled = True
Next
UserForm1.TextBox19.Enabled = True
UserForm1.CommandButton1.Caption = "Lock"
ElseIf UserForm1.CommandButton1.Caption = "Lock" Then
For i = 2 To 4
Controls("ComboBox" & i).Enabled = False
Next
UserForm1.TextBox19.Enabled = False
UserForm1.CommandButton1.Caption = "Unlock"
End If
End Sub
If I use this code above INSIDE the button code it works. Am I missing any coding?
A variable declared Public can be accessed either codes inside userform and moduels?
Thanks for your time!
Final