Results 1 to 8 of 8

Thread: [RESOLVED] Simulate button click in module

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Resolved [RESOLVED] Simulate button click in module

    Hey,

    I was wondering if it's possible (or how) to make a button be clicked (simulated) for a form. Is there a command to make a form think it's been pressed?

    I need to do this from within a module as the command buttons have too much code that wouldn't work directly in a module.

    Thanks

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Simulate button click in module

    You could do Form1.Command1.Value = True

    However, I can not image anything that could be run from a command button that couldn't be run from a Sub in a module. What do you have in this button?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Re: Simulate button click in module

    Quote Originally Posted by Hack
    You could do Form1.Command1.Value = True

    However, I can not image anything that could be run from a command button that couldn't be run from a Sub in a module. What do you have in this button?
    That gives me "method not found".

    The button changes menu text, captions, and calls functions.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Simulate button click in module

    Where is the command button (on what form)?

    What is the buttons name?

    How did you call the Sub that you put the code in?
    Last edited by Hack; Apr 13th, 2007 at 07:05 AM.

  5. #5
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: Simulate button click in module

    You will need to change the Buttons Property to PUBLIC from Private.. then
    you can call it from another form.


    Form1.Button1_Click()
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Simulate button click in module

    The click event of a button can be called from a sub in a module without changing anything. I will put together a little demo.

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Simulate button click in module

    Download the attached project, unzip it, load it and run it.

    First, click on File and take a look at the menu captions.

    Note the caption of Label1 and Text1.

    Open up the button that says "I will be called from the module"

    Now run it and click the button that says "Click Me". This button will run a Public Sub in the Module called 'ChangeStuff'

    ChangeStuff will:

    Change the caption of one of the menu items
    Change the caption of Label1
    Change the text of Text1
    Click the "I will be called from the module" button.
    Attached Files Attached Files
    Last edited by Hack; Apr 13th, 2007 at 07:33 AM.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    107

    Re: Simulate button click in module

    Thanks for that!

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