jwcolby
jwcolby at colbyconsulting.com
Wed Feb 11 11:09:25 CST 2009
Option Compare Database Option Explicit Private WithEvents mctlTxt As TextBox Private Const cstrEvProc As String = "[Event Procedure]" Private mlngBackColor As Long Private Const clngBackColor As Long = vbCyan Private Sub Class_Initialize() Set mctlTxt = Nothing End Sub Function mInit(lctlTxt As TextBox) Set mctlTxt = lctlTxt mctlTxt.BeforeUpdate = cstrEvProc mctlTxt.AfterUpdate = cstrEvProc mctlTxt.OnGotFocus = cstrEvProc mctlTxt.OnLostFocus = cstrEvProc End Function Private Sub mctlTxt_AfterUpdate() Debug.Print "AfterUpdate: " & mctlTxt.Name End Sub Private Sub mctlTxt_BeforeUpdate(Cancel As Integer) Debug.Print "BeforeUpdate: " & mctlTxt.Name End Sub Private Sub mctlTxt_GotFocus() Debug.Print "GotFocus: " & mctlTxt.Name 'Store the back color as we get the focus mlngBackColor = mctlTxt.BackColor 'Set the back color to an ugly light blue color mctlTxt.BackColor = clngBackColor End Sub Private Sub mctlTxt_LostFocus() Debug.Print "LostFocus: " & mctlTxt.Name 'Change the back color back to the original color mctlTxt.BackColor = mlngBackColor End Sub -- John W. Colby www.ColbyConsulting.com