[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
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?
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.
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?
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()
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.
1 Attachment(s)
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.
Re: Simulate button click in module