Calling Access Event Procedures

Posted on 2011-09-19
Last Modified: 2012-05-12
Hi Experts.

I have a form in Access that has about 2 dozen command buttons that each have an event procedure to run when clicked.  I would like to add one more button that would run the all the event procedures from all the buttons.  Is there a way to call these other 'on click' button events from the new button?

Thanks in advance.

Question by:JJINFM
LVL 120

Accepted Solution

Rey Obrero (Capricorn1) earned 250 total points
ID: 36562208

private sub newBtn_click()

end sub
LVL 10

Assisted Solution

VTKegan earned 250 total points
ID: 36562211
You can just simply call the btnAction1_OnClick() event in the code of the all button like below

Private Sub btnActionAll_Click()


End Sub
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36563492
You had better make sure you have some iron-clad error handling and/or rollback functionality in place...
In case one of the subs fails...
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

LVL 26

Expert Comment

ID: 36564212
<You had better make sure you have some iron-clad error handling and/or rollback functionality in place...
In case one of the subs fails...

True dat!

Even if your individual buttons have error handling, one of them failing may not bomb your mega-call, and if there are dependencies between these actions that could be bad
Copying and pasting the code from each button into a new procedure, with error handling might be prudent.
Building one big procedure that the 20 buttons call, passing in a parameter, that has a Select Case structure to deal with the piecemeal or mega-press might also be good.

But yes, they can all be called together like the first two posters have written
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36564282
Also some back ground would be nice...

<I have a form in Access that has about 2 dozen command buttons>
24 button on one form?

Why the need to do this?
What are these codes doing?

Just curious... case there is a more efficient approach...

Author Closing Comment

ID: 36576064
Thank you both.

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question