Disable and Lock a Textbox if Null - Set Focus

karmahum

Registered User.
Local time
Today, 14:57
Joined
Apr 29, 2002
Messages
53
Hello...I am not sure if there is a good way to do this...

I have a textbox that I want to become disabled and locked if the user Exits the control without entering any data. The problem is that I have to set the focus to another control on the form before I can lock and disable to the textbox...I understand this.

However, setting the focus to just some other control is not very user friendly if the user is using the mouse to jump to some other specific control on the form...

It is possible to capture the name of the "intended" control and set the focus there before locking and disabling the textbox they are exiting?

I hope this makes sense.

Thanks.
 
What if the user exited by accident? Is there a condition that would cause the control to become unlocked?
 
Hey Pat...Yes...

...there is a checkbox associated with the textbox that allows the users to "reactivate" the textbox. I know it sounds sort of hoaky, but I am not working with the brightest users...

Any Ideas?

P.S. How are things is Stratford? I actually do not live there anymore...
 
Well, the good news is that it is simple to do what you want. The bad news is, it is tedious.

Write a very small subroutine in your class module that does the control property changes you want.

Now put it in the _GotFocus routine of EVERY OTHER CONTROL on your form. (I told you it was tedious.)

In reading the thread, I see that you don't need to be warned about being unable to select a disabled, locked control. But perhaps all you REALLY need to do is to LOCK the control without disabling it. I believe you can still set .Locked = True in the control's _LostFocus routine. And maybe change its color or something equally visual to indicate the change. (After all, it IS called VISUAL Basic for Applications...)

If the control is locked, it can no longer be edited. Is that plus a visual change enough for your purposes?
 
Thanks for the Reply...Yes...

After seeing the suggested workaround...I am thinking that your method of only locking the textbox may be the solution...I had tried that and it worked fun...However, I thought I would at least ask if there was another way...

Thanks for the sugguestions!
 

Users who are viewing this thread

Back
Top Bottom