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

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
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
 
Upvote 0
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
 
Upvote 0
Copy the code from the sub "cmdPopulate_Click " into the
sub of "frmTimeSheet_open"
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,019
Members
448,938
Latest member
Aaliya13

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
Back
Top