Hello! I have written into my coding a facility that changes the BackColor (to light blue) when the field is GotFocus. The field BackColor returns to white on LostFocus. It works perfectly on about 10 fields in succession (Title, Initials, GivenName, FamilyName etc etc). However in one field (Company) on GetFocus, no problem but the cursor will not leave that field by using the tab or return. The AdComany form is a dialogue box that allows the user to enter a company name. If the name is in the Compaanies table already, the name is shown. If the company does not exist in the Companies table, the user enters a new company name. To leave that form there is a "Done" button, which closes the AddCompany form. What am I doing wrong? The code is as follows:
Code:
Private Sub Company_GotFocus()Dim ctl As Control
DoCmd.OpenForm "AddCompany", acNormal, "", "", acEdit, acNormal
DoCmd.RunCommand acCmdRefresh
Set ctl = Me.ActiveControl
If ctl.BackColor = 16777215 Then
ctl.BackColor = 15913666
Else
ctl.BackColor = 16777215
End If
End Sub