Get/Lost Focus

I

Ivan Grozney

My users want me to slightly change the color of the
control when it is selected. I use the GetFocus and
LostFocus and it works great (a pain for all the flippin'
control boxes but...).

The problems is when I go from a sub from back to the main
form. The subform control doesn't "lose focus" when I
switch back.

Any ideas how to have the subform's control lose focus
when I get back to the main form?

tia

Ivan
 
M

Marshall Barton

Ivan said:
My users want me to slightly change the color of the
control when it is selected. I use the GetFocus and
LostFocus and it works great (a pain for all the flippin'
control boxes but...).

The problems is when I go from a sub from back to the main
form. The subform control doesn't "lose focus" when I
switch back.

Any ideas how to have the subform's control lose focus
when I get back to the main form?


You can't make it "lose focus", but you can use the subform
control's Exit event to reset the color:

On Error Resume Next
subform.Form.ActiveControl.BackColor = vbWhite
 
K

Ken Snell [MVP]

Marsh -

You'd then need similar code in the subform's Enter event to reset the
color, right?
 
J

Jonathan Parminter

Hi, What about using conditional formatting from the
format menu?

Just an idea :)

Luck
Jonathan
 
I

Ivan Grozney

Marsh,

Works great! Thanks. Now I have a second form with a
subform within a subform and I cannot get it to work.

tia

Ivan
 
M

Marshall Barton

Neither can I. If you click on the main form when the
active control was in a subsubform, the subsubform control's
Exit event doesn't fire.

I suppose that you could get really tricky and use the
subform control's Exit event to reset the color in the
subsubform's Active control (even it has already been reset)

subform.Form.subsubform.Form.ActiveControl.BackColor=vbWhite

but this looks like it's getting pretty messy. Maybe your
users could just learn to live with it??

Actually, for the situation without a subsubform, I like
Jonathan's idea best. I hadn't realized that CF could do
that. Unfortunately, CF can't seem to keep track of the
subsubform situation either.
 

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