How To Click A Botton On Form1 From Form2 ?

Create a new project and add 2 forms create 1 button named command1 on form1 and then create another button on form2 called command1

The Code to click the button on form1 from form2 is:

Public Sub Command2_Click()
call Form1.Command1_Click
End Sub


'Please change the access modifier of the sub command1_click to public and not private


'like this:

Public Sub Command1_Click()
   MsgBox "Hello", vbOKOnly, "World"
End Sub
Member Avatar for deleted1234

Or you can try this on Form 1

Private Sub Command1_Click()
    Form2.Show
    Unload Me
End Sub

This on Form 2

Private Sub Command1_Click()
    Form1.Show
    Unload Me
End Sub
Form1.Command1.Value = True

Good Luck

technology's code will work fine. Use his code. Shinehah's code will just show form not click button on another form.
Good Luck

On form 1

Public Sub Command1_Click()

On form 2

Private Sub Command1_Click()

just change it to public....
then call

Form1.Command1_Click()

Why do that when you can do...

Form1.Command1.Value = True

from form2

Good Luck

lot of code gather. nice and nice.........its really make me happy:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.