Problems with SetFocus

  • Thread starter Thread starter Henry Christiansen
  • Start date Start date
H

Henry Christiansen

I have some text boxes on a form. I have tried to write a procedure in Lost
Focus that would test the length of the string input. If it is wrong, it
calls a message box to warn the operator. Then I set the focus back to the
text box where the input was made. But instead, focus goes to the next text
box in the tab order. I put in a Stop & it is definitely going through the
sub routine. Then I tried to direct it to another text box or to a command
button and it works perfectly. But whenever I try to direct it back to the
same text box from which it came, it won't. Help please!!!

Henry
 
Henry,

This is because it still has the focus and it can't refocus
to itself when it already has the focus.

Put your code in the BeforeUpdate event. This is the proper
place for data validation of a Control. If the string is the
wrong length, send your message and then put in...

Cancel = True

This will stop the update and leave the user in the control
until they get it right.

Gary Miller
Sisters, OR

"Henry Christiansen" <[email protected]>
wrote in message
news:[email protected]...
 
Back
Top