Running multiple command buttons

CCIDBMNG

Registered User.
Local time
Today, 00:49
Joined
Jan 25, 2002
Messages
154
Does anyone know if it's possible to run multiple command buttons under one command button without pasting the code for each under one. For example I have 4 different command buttons to run payroll for our 4 different clients in case we have to run just one. Is there a way for me to put a command button on my form to say run all. There is a lot of code for each command button so if I copy and paste there will be too much code under the one command button.
 
Just call the click event of the buttons you want from the Do All button

Private Sub Command0_Click()
MsgBox "BEEP"
Beep
End Sub

Private Sub Command1_Click()
MsgBox "BEEP"
Beep
End Sub
Private Sub Command2_Click()
MsgBox "BEEP"
Beep
End Sub

Private Sub btnDoAll_Click()
Command0_Click
Command1_Click
Command2_Click
End Sub

Hope this is what your looking for.
Drev
 
Thank You

That is exactly what I was looking for. Thanks. One question though will it run them all at once or will it wait for one to finish before it begins the next?
 
VBA runs through the code in sequence. Ergo, one at a time.

Also, instead of having Five buttons you could also set up a Sub Procedure for each of your clients. Have one Command Btn and 4 Check Boxes.

For your btnCommand_Click event you would have:

If me.ckOne = true then
procClient1
End if

If me.ckTwo = True Then
procClient2
End if

If me.ckThree = True Then
procClient3
End if

and so on.

In the end it probably doesn't matter which you use. But it's another way of going about what your doing.

Drev
 
I implemented it and it works perfectly thank you so much.
 

Users who are viewing this thread

Back
Top Bottom