Results 1 to 7 of 7

Thread: calling subs

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2000
    Location
    Galt, Ca
    Posts
    47

    Angry calling subs

    does anyone know how to call sub from another form?

    for example, i am working with form 1, but i need to call a command1_click() from form2, does anyone know how to do this?

    -emptywords

  2. #2
    wossname
    Guest
    Dead easy.
    There are 2 ways to do this...

    Change the Command1_Click Event to Public instead of Private. Then in Form2 use...

    Code:
    Call Form1.Command1_Click
    Or, you could dump all the code from that event into a public sub inside a module, then you can call that code from any form you like.

    The second way is safer, but make sure it doesnt throw any of your variables out of scope.

  3. #3
    Matthew Gates
    Guest
    You could also set it's Value property to True, which will also call the Command1_Click event.


    Code:
    Form2.Command1.Value = True

  4. #4
    wossname
    Guest
    Matthew, yeah but why do it the easy way when you can risk throwing all kinds of bugs into the program with my method!

    ps. Won't your way force a refresh of the button's graphical DC clipping region?

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Is that a particular problem?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    Megatron
    Guest
    Originally posted by Matthew Gates
    You could also set it's Value property to True, which will also call the Command1_Click event.
    Not all controls have a Value property. Also, What if the sub being accessed was not an sub linked to an object?

  7. #7
    Matthew Gates
    Guest
    Only talkin' about a Command Button here .

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