setfocus on form load

G

Guest

Hi,
I have a form that is designed to have fields change color on "gotfocus."
This was done with this code:

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

It goes back to white on lostfocus.
It works fine until the form is closed and reopened. Then I get a runtime
error msg # 2474 that says "The expression you entered requires the control
to be in the active window"
Going to debug, the 2nd line of the above code is highlighted.

Looking @ other potenial solutions...Oncurrent for form =
Me!txtCertNo.SetFocus does not work. When I end the debug, the cursor is in
the 1st tab order box, which is txtCertNo, but it is with a white background,
rather than cyan.

Please advise & thank you!
Karl
 
G

Guest

Yes, it is set to 0 now, but still had that error msg. I was able to work
around the problem by putting in another rectangle behind that field and
putting the highlight color to white and the CertNo field to Cyan, with
backstyle transparent.

Thank your for your response,
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