Option Compare Database
Option Explicit
Dim NameOfActiveControl As String
'Private Const ActiveForeColor As Long = 16711680 'color contents button
Public Sub ChangeColor(ActiveForeColor As Long, _
NameOfActiveControl As String, _
NameOfControl As String)
'If name active and current the same yet then to exit....
If NameOfActiveControl = Me(NameOfControl).Name Then
Exit Sub
End If
'If some control was activated before so deactivating it
If Len(NameOfActiveControl) > 0 Then
Me(NameOfActiveControl).ForeColor = -2147483630
End If
'Set name for new active control
NameOfActiveControl = Me(NameOfControl).Name
Me(NameOfControl).ForeColor = ActiveForeColor
'Change color of contents
Me(NameOfActiveControl).SetFocus
'Set focus on button
End Sub