Setfocus on form load

G

Guest

Hi,
I made a form where the fields change color on focus. It worked fine during
construction, but when the form is closed and re-opened a Runtime error 2474,
"The expression you entered requires the control to be in the active window."

When I hit the debug option, it highlights the second line of this code:

Private Sub txtCertNo_GotFocus()
Screen.ActiveControl.BackColor = RGB(0, 255, 255)
End Sub

I've tried, in the form properties OnCurrent, writing Me!txtCertNo.SetFocus,
but it doesn't work--saying Can't find the macro 'Me!txtCertNo.SetFocus'

Trying in the same OnCurrent area: =Me!txtCertNo.SetFocus doesn't work, and
neither does writing in the code:

Private Sub Form_Current()
Me!txtCertNo.SetFocus
End Sub

Please advise & thank you for your time!
Karl
 
G

Guest

Looking at Dirk's response to another person, I tried just making the
backstyle on this text box transparent and making the highlight color the
cyan color and elilminating the code for "gotfocus". The other idea of
putting a rectangle behind the field made the text disappear when the next
field was selected. Perhaps that means the rectangle was actually in front.
I'll see if I can figure how to make it behind.
Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top