Lost Focus event, unable to make control invisible

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I am having trouble with the Lost Focus event for a text box. I am trying
to make it invisible (so I can make another visible) as the user leaves it.
When I try to execute this, I get an error stating that I can't hide a
control that has the focus. I find this odd, isn't this event supposed to
fire after the control loses the focus? I do not want to explicitly set the
focus elsewhere, as then tabbing or clicking elsewhere would not immediately
set the focus there. Btw, I get the same error attempting On Exit.

Is there a way around this? If not, I can explain the situation, as I am
open to a completely different solution.

s
 
My error; yes you did.

You'll need to change the visibility using one of the events for the control
that is getting the focus after this textbox then.
 
That's what I was afraid of. If they're just tabbing around, it would be
simple enough to add it to the controls on either side. However I have about
30 controls that can be moused to.

BUT!! I just (about eight minutes ago) figured out a different way. The
two controls I'm working with are occupying the same space. So instead of
switching visibility, I sent #2 to the back. #2 now does not need to be made
invisible at all - when it loses focus, it hides behind #1 by making it (#1)
visible. Problem solved.

Thanks,
s
 
scojerroc said:
That's what I was afraid of. If they're just tabbing around, it would be
simple enough to add it to the controls on either side. However I have
about
30 controls that can be moused to.

BUT!! I just (about eight minutes ago) figured out a different way. The
two controls I'm working with are occupying the same space. So instead of
switching visibility, I sent #2 to the back. #2 now does not need to be
made
invisible at all - when it loses focus, it hides behind #1 by making it
(#1)
visible. Problem solved.

Yep, that is a commonly used technique for this type of setup -- but you
didn't tell us were "toggling" between two overlaying controls.. < grin >.
 
Kirstie Adam said:
this is exactly what i am trying to do, can you tell me how you did it?

kirstie

The two controls i am working with are txtUPB and txtDisplayUPB. the
control source for txtUPB is "UPB". the control source for txtDisplayUPB is
"=CDbl([UPB])" and the format property is set to "Currency". (this is
because the UPB field is text in the table. i cant change that. i think
that if the UPB field were Currency to begin with, this whole exercise would
be unnecessary.)

in the txtUPB LostFocus code, i've got "Me.txtDisplayUPB.Visible = True"
txtDisplayUPB GotFocus: "Me.txtUPB.SetFocus" and "Me.txtDisplayUPB.Visible =
False"

finally, i've got both controls occupying the same space on the form: the
Format menu (on the menu bar, you can't right click this one). the bottom
two options are "Bring to Front" and "Send to Back". txtUPB was Sent to
Back, txtDisplayUPB was Brought to Front.

i'm pretty sure i covered everything. let me know if this does not work.
 
Back
Top