Interesting idea Andy, in effect you're simulating clicking the command button. It never occurred to me that you could do it that way, in fact. However, the underlying concept isn't something that you'd want to use on all types of event handler. For example, you'd have to put some sort of dummy character into a text box to invoke a change event, and then of course ignore the second change event that occurs when you take it out again.
So, another way to invoke event handlers is by simply calling them. (jozino, you were on the right track!) They're procedures just like any other, and so can be called just like any other. Now, the problem in this case is that you're trying to call the handler from another form, and event handlers are private by default. You can handle this in either of two ways: put a public sub in the target form that calls the click event procedure, and call that from the calling form, or simply make the click event procedure public and call it directly.
To illustrate this, put two forms in a project. Put a command button on each. Now, for the first technique, on form2, put the following code:
Code:
Private Sub Command1_Click()
MsgBox "click"
End Sub
Public Sub ClickCommand1()
Command1_Click
End Sub
On Form1, put the following code:
Code:
Private Sub Command1_Click()
Form2.ClickCommand1
End Sub
Private Sub Form_Load()
Form2.Show
End Sub
Now, for the second technique, on form2, put the following code:
Code:
[COLOR=red]Public[/color] Sub Command1_Click()
MsgBox "click"
End Sub
On Form1, put the following code:
Code:
Private Sub Command1_Click()
Form2.Command1_Click
End Sub
Private Sub Form_Load()
Form2.Show
End Sub
Now, I don't mean to say that you shouldn't use Andy's solution. I might even use it myself, now that I know it works! But I believe it's important to know all this other stuff, because it lets you invoke any kind of event handler on a different form, not just the command button click event.
Bob