Results 1 to 4 of 4

Thread: Need help with multiple forms communicating with eachother

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Cliffwood Beach, NJ, USA
    Posts
    6

    Post

    I am designing an app with multiple forms. I havn't found any good documentation as to how to communicate between forms. My current need is this: I have one form with a button that loads another form. This second form has an OK & a Cancel button on it. I need to know in the parent form which button was clicked. I could set a global variable in form2 but I'm hoping there is a cleaner way of doing this.

  2. #2
    Hyperactive Member
    Join Date
    Sep 1999
    Posts
    305

    Post

    If that form only has an OK and a cancel button, consider using a message box instead. That will do what you want.

  3. #3
    Addicted Member
    Join Date
    Jan 2000
    Location
    Sydney, Australia
    Posts
    196

    Post

    Theres a couple of other things you can try:

    Hopefully you don't wantthe user to go back to the first form when the second one is open

    1) You can have a private variable in the second form that is set when you click either ok or cancel. Then you can just hide the form and test the value in the original form. ie:

    within form1:

    form2.show vbmodal
    the_result = form2.the_private_variable

    bla bla

    2) Create a class that opens the second form when some method is called. The "display" method can get the result (similarly to above) and then return it as it's return value. This way jsut "wraps" it up a bit more and makes it a bit neater i suppose. Although there a most likely processing overheads doing it this way.

    HTH

    Mark

  4. #4
    New Member
    Join Date
    Feb 2000
    Posts
    8

    Post

    Similar to what funkyd77 said:

    Form1 event:

    Form2.Show 1
    MsgBox Form1.Tag

    Form2 event:

    Form1.Tag = "Hi!"
    Unload Me

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width