How do I create a single onClick sub for multiple command buttons.
Posted on 2006-06-08
I have been given an Access MDB to convert to an ADP. Part of the work is to speed things up and make the code "better".
One part of the application is a touch screen keypad.
Each "button" is a command button. Each button has a tag indicating its value.(0 to 9).
Each button has a separate onclick event handler.
I want to use a single event handler for all buttons.
In Delphi, I can do this and the first parameter of the onclick event handler is the object that generated the click event (normally the button).
So 10 buttons all with the same onclick event handler can be done as the first parameter would be obj_cmd_button and obj_cmd_button.tag would give the tag value (which is all I'm interested in).
How do I do this in MS Access.
Currently the subs are ...
Private Sub cmd0_Click()
On Error GoTo Err_cmd0_Click
With 10 of them, it is a bit of a pain.
Now extend that to the alphanumeric keypads!!!! 36 nearly identical subs!!!!
Is there a parameter I can add (like there is in Delphi) ?