Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling controls 2

Status
Not open for further replies.

ind

Programmer
Mar 9, 2000
121
US
I have the following code:<br>Private Sub strActive_AfterUpdate()<br>Dim ctl As Control<br><br>For Each ctl In Forms!frmCustomers<br>&nbsp;&nbsp;&nbsp;&nbsp;If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox And strActive = 0 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;With ctl<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Enabled = False<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End With<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox And strActive = -1 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;With ctl<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Enabled = True<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End With<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>Next<br>End Sub<br><br>This function only disables the comboboxes and not the textboxes. How can I make it do both??<br><br>Thanks for the Help!
 
Try this...<br><FONT FACE=monospace><br>Private Sub strActive_AfterUpdate()<br>Dim ctl As Control<br><br>For Each ctl In Forms!frmCustomers<br>&nbsp;&nbsp;&nbsp;&nbsp;If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If strActive = 0 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ctl.Enabled = False<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ctl.Enabled = True<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>Next<br>End Sub<br></font><br> <p>Jim Conrad<br><a href=mailto:JimConrad@Consultant.com>JimConrad@Consultant.com</a><br><a href= > </a><br>
 
Have you tried using parentheses?<br><br>If (TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox) And strActive = 0 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>Kathryn<br><br>
 
Thank you both <br>Each method worked great
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top