Results 1 to 10 of 10

Thread: Click

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Location
    I'm right here!
    Posts
    849

    Question Click

    How can I call a click procedure of a command button from another form?
    Dekel C.

  2. #2
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961
    u cannot call a click procedure of a button of another form because it is private to that form. u can do one thing. create a public procedure in your start up module. And you can call that procedure from any form.

    hope this will solve your problem

    regards,
    prakash

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    You don't necessairly have to put a sub in a module. You can make a Public sub on a form. If the sub on the form is Public, it can be called from another form.

  4. #4
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961
    can we declare a public sub in the form? i am not sure!!

  5. #5
    Fanatic Member
    Join Date
    Feb 2002
    Location
    SE England
    Posts
    732
    Create Public Sub in the form with the click event...

    Public Sub RunClick()
    CommandButton1_Click
    End Sub

    The call this from wherever it is needed..

    MyForm.RunClick
    Leather Face is comin...


    MCSD

  6. #6
    Fanatic Member
    Join Date
    Feb 2002
    Location
    SE England
    Posts
    732
    An easier alternative is to simply use the following..

    MyForm.CommandButton1.Value = True

    This will run the click event of commandbutton1 and does not require any extra subs...
    Leather Face is comin...


    MCSD

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Calling click events from buttons of any sort on a different form poses a problem in that all click events are Private to the form. It is better to create a Public sub on the form. That can be accessed easily.

  8. #8
    Fanatic Member
    Join Date
    Feb 2002
    Location
    SE England
    Posts
    732
    Yes, but all controls on a form are available...

    So are there properties...

    Setting the value property of a command button to true fires its click event...
    Leather Face is comin...


    MCSD

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Originally posted by Leather
    Setting the value property of a command button to true fires its click event...
    You are correct providing the button resides on the same form that is doing the calling.

  10. #10
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    Originally posted by Hack
    You are correct providing the button resides on the same form that is doing the calling.
    NO NO NO not true. Try this
    form1
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     Form2.cmdTest.Value = True
    5. End Sub
    Form2
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub cmdTest_Click()
    4.     MsgBox "Form2"
    5. End Sub

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