I understand you want to change the BackColor of a Control in a Form
displayed in Single Form View to vbCyan when that Control receives the Focus
and revert to its original BackColor when it loses the Focus. If that is
not correct, post back and clarify.
You don't have to get "fancy" with class modules... besides which, I see
nothing to be triggered by the control receiving the focus in yours.
In the General Declarations section of the Form's module, put:
Dim lngSavedColor As Long
Then, still in the General section, add:
Private Function CyanBack()
lngSavedColor = Me.ActiveControl.BackColor
Me.ActiveControl.BackColor = vbCyan
Function
Private Function OldBack()
Me.ActiveControl.BackColor = lngSavedColor
End Function
And in the GotFocus event of each Control where you want this behavior:
= CyanBack()
And in the LostFocus event of each Control where you want the behavior:
= OldBack()
That said, a more common color for highlighting controls would be Yellow, or
Light Yellow, but, I admit, your cyan does show up.
Larry Linson
Microsoft Access MVP
"x taol" <to******@yahoo.comwrote in message
news:45*********************@news.qwest.net...
'class module
Public WithEvents clsTxt As TextBox
Private Sub clsTxt_Enter()
clsTxt.BackColor = VBA.ColorConstants.vbCyan
End Sub
'form module
Dim txt(1) As New Class1
Private Sub Form_Load()
Set txt(0).clsTxt = Me.Text0
Set txt(1).clsTxt = Me.Text1
End Sub
i want to change the backcolor of the textbox control when the user
focusing in the textbox control.
but the upper source code doesnot work.
*** Sent via Developersdex http://www.developersdex.com ***