Disabling a Control On Exit

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Sprinks (Sprinks_at_discussions.microsoft.com)
Date: 12/03/04


Date: Fri, 3 Dec 2004 11:05:01 -0800

I've created a simulation of an Excel cell in one of my forms, such that the
user can enter a formula, but in leaving it displays the result. This is
implemented by two overlapping controls, txtFormula and txtResult.
txtFormula is bound to an underlying table field, while Result just displays
0 or the result of a Call to the Eval function.

txtResult is set to Enabled and Visible. In the OnGotFocus event, it makes
txtFormula Visible and Enabled, sets the focus there, then disables itself
and makes itself invisible.

I'd like to do just the opposite when I leave txtFormula, but I can't
disable it when it has the focus, which it does when called from the OnExit
or OnLostFocus event. I can do so from the OnEnter or OnGotFocus event of
the next control, which works fine, but the user *could* move backwards or
mouse-click into another control, in which case txtFormula would remain
enabled and visible. The only way I've been able to get it to work is to put
the code in the OnGotFocus event of each enabled control. While this works
now, I'd certainly like to know if there's a better way to do this for next
time. Can anyone tell me how?



Relevant Pages

  • RE: Disabling a Control On Exit
    ... you choose then disable the control: ... > implemented by two overlapping controls, txtFormula and txtResult. ... In the OnGotFocus event, it makes ... > txtFormula Visible and Enabled, sets the focus there, then disables itself ...
    (microsoft.public.access.forms)
  • RE: Disabling a Control On Exit
    ... Thanks for taking the time to respond, Jason. ... > you choose then disable the control: ... >> implemented by two overlapping controls, txtFormula and txtResult. ... In the OnGotFocus event, it makes ...
    (microsoft.public.access.forms)
  • Re: Last Key Pressed/Move In Direction
    ... When the user enters the cell, ... and sets the focus to the txtFormula control. ... > Private Sub txtFormula_LostFocus ...
    (microsoft.public.access.forms)
  • Last Key Pressed/Move In Direction
    ... OnFocus event procedure disables the cell and makes it ... and sets the focus to the txtFormula control. ... Private Sub txtFormula_LostFocus ...
    (microsoft.public.access.forms)