Results 1 to 5 of 5

Thread: Validate Event with SetFocus or ENTER key

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Posts
    2

    Post

    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.

  2. #2
    Lively Member Maartin's Avatar
    Join Date
    Jan 2000
    Location
    Benoni, Gauteng, South-Africa
    Posts
    99

    Post

    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 ?

  3. #3
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386

    Post

    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.

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Posts
    2

    Post

    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.

  5. #5
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386

    Post

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width