| Author |
How can I Click a menu item from code in another form?
|
|
| Stan Hilliard 2005-04-09, 3:58 pm |
| How can I Click a menu item from code in another form?
I have tried these but they didn't work:
1) MDIForm1.mnuDesign(1) = True
2) Call MDIForm1.mnuDesign(1)
The sub that the menu calls is:
Private Sub mnuDesign_Click(Index As Integer)
Help will be appreciated, Stan Hilliard
| |
| Rick Rothstein 2005-04-09, 3:58 pm |
| > How can I Click a menu item from code in another form?
>
> I have tried these but they didn't work:
>
> 1) MDIForm1.mnuDesign(1) = True
>
> 2) Call MDIForm1.mnuDesign(1)
>
>
> The sub that the menu calls is:
>
> Private Sub mnuDesign_Click(Index As Integer)
>
> Help will be appreciated
Place the code that you have in the menu item's Click event into a Sub
(having an Integer argument in order to receive the Index value)
instead; then call the Sub (passing the Index value to it) from the menu
item's Click event and also from your code directly.
Rick - MVP
| |
| Steve Gerrard 2005-04-09, 3:58 pm |
|
"Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> wrote in message
news:08tf51l7lc3u44t126dtslouh0oo10rfig@
4ax.com...
> How can I Click a menu item from code in another form?
>
> I have tried these but they didn't work:
>
> 1) MDIForm1.mnuDesign(1) = True
>
> 2) Call MDIForm1.mnuDesign(1)
>
>
> The sub that the menu calls is:
>
> Private Sub mnuDesign_Click(Index As Integer)
>
You could change the event handler declaration to
Public Sub mnuDesign_Click(Index As Integer)
and then on another form you could write
Call MDIForm1.mnuDesign_Click(1)
The "nicer" style for coding this would be, in the MDIForm,
Private Sub mnuDesign_Click(Index As Integer)
Call DoDesignChange(Index)
End Sub
Public Sub DoDesignChange(ByVal Num As Integer)
' actually do it here...
End Sub
And from another form,
Call MDIForm1.DoDesignChange(1)
Which leaves the event handler as it should be, and puts the real business in a
suitably named procedure.
|
|
|
|