Yes, you need to put this in the events of each control, but you can do that
programmatically.
The following example opens the form in design view, and sets the OnGotFocus
and OnLostFocus properties of all the text boxes and combo boxes:
Function SetupHightlight(strForm As String)
Dim ctl As Control
Dim strName As String
DoCmd.OpenForm strForm, acDesign
For Each ctl In Forms(strForm).Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox
strName = ctl.Name
ctl.OnGotFocus = "=HighLight([" & strName & "], True)"
ctl.OnLostFocus = "=HighLight([" & strName & "], False)"
End Select
Next
Set ctl = Nothing
End Function
Public Function Highlight(ctl As Control, bHighlighted As Boolean)
If bHighlighted Then
ctl.BackColor = vbYellow
Else
ctl.BackColor = vbWhite
End If
End Function
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
Anne said:
You have to put this in every field? Isn't there one you can use on open
of
the form?
Anne