Results 1 to 5 of 5

Thread: Validate event with menu

  1. #1

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Question Validate event with menu

    Hi Everybody !

    Is it normal that the validate event is not fired when I click in menu ???

    Thanks in advance !

    Note: NEVER USE SSTAB ! I LOST 2 HOURS TO REPLACE IT BY TABSTRIP !
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Validate event with menu

    Yes, the focus doesn't leave the control when you go to a menu. Focus only escapes to other controls on the form; a menu isn't counted as a regular control in this case, it isn't within the same container as the other controls.


    For a quick test:
    VB Code:
    1. Private Sub Text1_GotFocus()
    2.     Debug.Print "GotFocus"
    3. End Sub
    4.  
    5. Private Sub Text1_LostFocus()
    6.     Debug.Print "LostFocus"
    7. End Sub
    8.  
    9. Private Sub Text1_Validate(Cancel As Boolean)
    10.     Debug.Print "Validate"
    11. End Sub

  3. #3

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Validate event with menu

    Ok ! The problem I have it's:

    1) I Click in Textbox
    2) I Erase text into it
    3) I Click on menu "Close Project"
    4) The programm ask if the user wants to save or no, if its yes I got an error because de Textbox is empty, and I need the value in the Textbox...

    Suggestion ??? Thanks !
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Validate event with menu

    Call the Form's ValidateControls method in the Menu Click event. You will need to setup error handling as ValidateControls raises an error if the control fails validation.

    Note: NEVER USE SSTAB
    Why? I use it all the time. Never had any problems.

  5. #5

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Validate event with menu

    Thanks for your suggestions !

    Quote Originally Posted by brucevde
    Why? I use it all the time. Never had any problems.
    You can check this link to understand why...
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

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