In order to visually inform the user that the subform is read only, many
developers set the Locked property of the Subform or the controls and the
BackColor property of the controls to True. But whenever the
subform loses focus, the first control remains selected which changes it's BackColor to
Normal. This can be annoying.
To fix this behavior:
- Create another dummy textbox (txtDummy) on the subform.
- Set it's Width and Height properties to zero.
- Set it's Locked property to True.
- Move this textbox to the very top of the TabOrder under View |
- Include this code in the parent form in the subform's Exit event.
Private Sub SubFormName_Exit(Cancel As Integer)
On Error Resume Next