Click Command Button using Code

Serious Sam

New Member
Joined
Jan 19, 2005
Messages
30
Hello,

I have a form where a person's timesheet data is entered - frmTimeSheet
I have a button on this form that when clicked, populates the timesheet with standard hours - cmdPopulate_Click()

What I am hoping to do is have a seperate form with a button than when clicked on

1. Opens up the frmTimeSheet - docmd.Openform etc
2. Automatically clicks the cmdPopulate button.

Is it possible to click a button, that then makes another button click?

Or is there a better way altogether?
Any ideas much appreciated
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
Sam, you can do this:

1. Create a button that opens your form.

2. In the form that opens, go to the Properties and select the Open event. Double-click the blank line so it shows Event Procedure. Now click the Builder (...) button at the end of the row to go to the code window.

3. In the code, between Private Sub... and End Sub, type this:
cmdPopulate_Click

This will cause the Populate button's Click event to run as the form loads.

Denis
 

Serious Sam

New Member
Joined
Jan 19, 2005
Messages
30
Hi Denis,

Thanks for that. That would work well except the form needs two other text boxes populated first (Name and Weekending) before the cmdPopulate runs.
Is there another way of making it run?
I tried putting the code on the AfterUpdate of the second text box, but hat didn't work.
Thanks Mate
 

perryd

New Member
Joined
Dec 15, 2005
Messages
6
Copy the code from the sub "cmdPopulate_Click " into the
sub of "frmTimeSheet_open"
 

Forum statistics

Threads
1,136,345
Messages
5,675,223
Members
419,553
Latest member
hanahass

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top