7
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by abu taher
0

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

Edited by technology: n/a

0

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
0

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

0

On form 1

Public Sub Command1_Click()

On form 2

Private Sub Command1_Click()

just change it to public....
then call

Form1.Command1_Click()
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.