Click to See Complete Forum and Search --> : Validate Event with SetFocus or ENTER key
powersoft
Jan 17th, 2000, 11:38 AM
The validate event is not activated by either (a) using code (ie. SetFocus method) to set focus to another control or (b) pressing <enter> when there is a command button with its Default property set to TRUE.
I want to validate my textbox entry in both of these situations. Any suggestions?
Thanks.
Maartin
Jan 17th, 2000, 12:06 PM
This might not be the extact answer you are looking for but here goes.
Why don't you do the validate under the text box lost focus ?
Crazy D
Jan 17th, 2000, 03:23 PM
The validate event only occurs when the control that will receive the focus has the property CausesValidation set to true. At least, according to the helpfile... press F1 to find out...
And why not in the LostFocus? Sure, the lostfocus you can validate too, but if you wish to keep the focus on the control (not my favorite thing though) you better use the validate event. Setting focus in the lostfocus is not so smart.
powersoft
Jan 17th, 2000, 08:09 PM
I do have the Causes Validation in my other controls set to TRUE. Also, I was trying to get away from doing validation in LOST FOCUS - partly because the control does not lose focus when you use the ENTER key to activate the default command button, and partly because the help file tells you its better to validate in VALIDATE not LOST FOCUS.
Validating in LOST FOCUS does solve the problem for using .SETFOCUS to move to another control but does not solve the problem for using the <ENTER> key.
Crazy D
Jan 17th, 2000, 08:30 PM
If everything else fails you can always use the keydown event, check the keycode to see if it's vbKeyReturn, and then do what you want.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.