Stu,
I had the same problem & have a great solution. Wish I could take credit for it but I can't. I got my help from Gyula Gulyas over at allexperts.com.
1. Insert this code into a new module
2. Replace "Table1" with your form name
3. Run the FormFiller (by placing your cursor next to the "Sub Formfiller" line and hitting F5)
This will place the function calls into the GotFocus and LostFocus events of each control that is a textbox type.
---------- code starts here -----------
Public Function TextGotFocus(strFrmName As String, strCtrlName As String)
Dim dbs As Database
Dim frm As Form
Dim ctrl As Control
Set dbs = CurrentDb
Set frm = Forms(strFrmName)
frm.Controls(strCtrlName).BackColor = 10079487
End Function
Public Function TextLostFocus(strFrmName As String, strCtrlName As String)
Dim dbs As Database
Dim frm As Form
Dim ctrl As Control
Set dbs = CurrentDb
Set frm = Forms(strFrmName)
frm.Controls(strCtrlName).BackColor = vbWhite
End Function
Sub Formfiller()
Dim dbs As Database
Dim frm As Form
Dim ctrl As Control
Set dbs = CurrentDb()
DoCmd.OpenForm "Table1", acDesign
Set frm = Forms("Table1")
For Each ctrl In frm.Controls
If ctrl.ControlType = acTextBox Then
ctrl.OnGotFocus = "=TextGotFocus(""" & frm.Name & """,""" & ctrl.Name & """)"
ctrl.OnLostFocus = "=TextLostFocus(""" & frm.Name & """,""" & ctrl.Name & """)"
End If
Next ctrl
DoCmd.Close acForm, "Table1", acSaveYes
End Sub
----------- end of code -------------
Hope it helps!
Mike