1 Attachment(s)
Clicking on a menu item does not cause the object validate to trigger, why?
As simple as I could put it in a VB program, the msgbox in the Validate event does not get fired when you click on the menu item "Print" which calls the Click event. I expect the Validate event to get fired but it doesn't. It gets fired only when you click on the command button.
I understand that the textbox object has not lost its focus. How do I get it to lost its focus so that the Validate event can get fired. I have about 200+ objects that I create and destroy on the fly, depending on the user's action. I need something simple or quick to solve this.
Any ideas on how to get it fired? Otherwise I may have to remove the menu items. The reason why I want it fired is that so whatever the textbox contains can get assigned to a class object property before it gets printed. It is assigned in the Validate event if it passes the requirements. Not all events do some validation checking prior to assigning the value to the class object. Like I said I have over 200 objects (or class properties) so I can't know which one is loaded or not on the spot. (Trying to do so is so much work, especially when I don't know which object has the focus. I don't really need to know it.)
Clicking on the menu item is similar to the command button CauseValidation = False. I want it to be "True"
To give you a small info on the project, it is a report generator program. It has over 50 reports, depending on the report the user selects, it will display a small number of options for that report. Many reports share some of the same options (that's why I have a class module) When the user wants to print the report, the object that currently has focus doesn't fire the Validate event if you choose the menu item. That's why I don't which report option has the focus.
You could call it explicity...
I know this is only a workaround, but I am afraid there is something related to menu (ie: kind of callback mechanism) that interfers with set/get focus.
I tried switching explicitly the focus (in the mnufileprint_click event) to text1 and then to command1, but no event rised.
But you can call explicitly the validate event:
Code:
Private Sub mnuFilePrint_Click()
'call validate method
Text1_Validate False
Call Command1_Click
End Sub