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 !
Printable View
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 !
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:
Private Sub Text1_GotFocus() Debug.Print "GotFocus" End Sub Private Sub Text1_LostFocus() Debug.Print "LostFocus" End Sub Private Sub Text1_Validate(Cancel As Boolean) Debug.Print "Validate" End Sub
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 !
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.
Why? I use it all the time. Never had any problems.Quote:
Note: NEVER USE SSTAB
Thanks for your suggestions !
You can check this link to understand why...Quote:
Originally Posted by brucevde