Link to home
Start Free TrialLog in
Avatar of thang74us
thang74us

asked on

Run 1 Command in Form2

I have 2 Form (name: Form1 and form2)

I want, When Click  Command19 of Form1 then load Form2 and wite msgbox "Comamnd19" and When Click Command20 of Form1 then load Form2 and wite msgbox "Comamnd20"

Help me!
Thank you
ASKER CERTIFIED SOLUTION
Avatar of Rimvis
Rimvis
Flag of Lithuania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RuzRey
RuzRey

Try adding a module to your project. In the Module:-

Global sCommandToDo as string

Then in form2:-

Private Sub Form_Load()
  if sCommandToDo <> "" then
    MsgBox sCommandToDo
  end if
End Sub

In form1 you set sCommandToDo to the message you want, before loading form2:-

Private Sub Command19_Click()
  sCommandToDo = "Command19"
  load Form2
  Form2.Show
End Sub

Private Sub Command20_Click()
  sCommandToDo = "Command20"
  load Form2
  Form2.Show
End Sub

A global can be seen by any form in your project.

Ruz
Avatar of thang74us

ASKER

Thank RuzRey