| Re: LostFocus Event help -
06-04-2007, 08:57 AM
"Bob Butler" <EMAIL REMOVED> wrote in message
news:EMAIL REMOVED m...
> "Randi" <EMAIL REMOVED> wrote in message
news:<R9TCb.11784$EMAIL REMOVED>.. .
> > Hi All,
> > I have a problem on a username p***word login form. I use:
> > txtP***word.Text = StrConv(txtP***word.Text, vbProperCase) to
validate the
> > proper case when someone enters their name and p***word. It work
when you
> > use the button to continue, but if you hit enter on your keyboard
the event
> > apparently doesnt lose focus and it says you entered the wrong
p***word.
>
> Neither the LostFocus nor Validate events are reliable IMO because
> they do not fire consistently. Clicking toolbar buttons, menu items
> and pressing enter to trigger the default command button are just a
> few cases where they don't happen. You can use them for simple
> validation if you want but never ***ume that they will run. In this
> case, have the command button code do the StrConv.
I would say the events are reliable, but that controls don't lose focus
in some situations where you might expect them to. I agree that you
should never ***ume they will be fired, and always put required
processing in a procedure that will definitely run.
LostFocus doesn't fire here because in fact, the textbox never loses
focus. If the default button only popped up a message, focus would
return to the textbox, not the default command button. Similarly,
Validate doesn't fire because it only fires just before a possible loss
of focus.
In many cases, it makes sense that selecting a menu or toolbar button
does not change the focus. If I click the Paste button, for instance, I
appreciate the fact that the focus stays where it is, and the paste
occurs where I intended it. |