Lost Focus event, unable to make control invisible

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
 
K

Ken Snell \(MVP\)

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.
 
G

Guest

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
 
K

Ken Snell \(MVP\)

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 >.
 
G

Guest

Yeah, I can make poor choices on what details to omit for the sake of
brevity. Sorry. :)
 
K

Kirstie Adam

this is exactly what i am trying to do, can you tell me how you did it?

kirstie
 
G

Guest

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.
 

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

Similar Threads

Cancel On Lost Focus Event 3
Lost Focus Woes 7
Kill Focus on Subform 2
Focus after DblClick 4
Focus jumps a control 2
Keeping Focus on Control 4
subform LostFocus 1
lost focus 6

Top