Problem is the end users often move around the Form using the mouse and clicking into controls they want to update, so I am trying to find a way of firing the code from a Form MouseDown or Click event. Obviously I could put a reference to the Sub Routine in each individual control to call it on Click, but that means repeating it over 200 times. There must be a simpler way!
Here is the code that works on Form KeyPress event (variable iTabPage is the Tab page value, so I only loop through the Page with the focus)
Expand|Select|Wrap|Line Numbers
- Dim Ctl As Control
- For Each Ctl In Me![TabCtl].Pages(iTabPage).Controls
- If Ctl.ControlType = acTextBox Or Ctl.ControlType = acComboBox Then
- Ctl.BackColor = IIf(Ctl.Name = Screen.ActiveControl.Name, 8454143, 16777215)
- End If
- Next