mistux Site Admin
Joined: 25 Jun 2004 Posts: 1042 Location: South Bend, Indiana USA
|
Posted: Thu Oct 23, 2008 3:30 pm Post subject: Loop through controls and change color |
|
|
If you are like me and have an Edit button that changes the background color of my text boxes from gray to white then use this code to do that:
Code: |
Private Sub btnEdit_Click()
On Error GoTo Err_btnEdit_Click
For Each ctl In Me.Controls
If ctl.ControlType = acComboBox Or ctl.ControlType = acTextBox Then
ctl.BackColor = RGB(255, 255, 255) 'White
End If
Next
'FYI RGB(216, 216, 216) 'gray
Exit_btnEdit_Click:
Exit Sub
Err_btnEdit_Click:
If Err.Number = 438 Then Resume Next 'subform
MsgBox Err.Description & " Number: " & Err.Number
Resume Exit_btnEdit_Click
End Sub
|
|
|