Entering expressions like "=SubroutineXYZ("lbl12")" instead of "[Event Procedure]" in Access' property sheet of form controls events, like OnClick

I've seen it done in Access 2000, but now I'm trying to do it in Access 2007 and it doesn't work. That would be very useful, for example, when a large group of buttons basically do the same thing, like in calendars for example.

Instead of using the Code Builder to generate a large number of Subs like these:

Sub cmdXY_Click()
   Call HandleButton(ButtonCoords:="XY")
End Sub

... I was able to simply write "=HandleButton("XY")" statements in the property sheet of their OnClick events. In Access 2007 I'm getting an error message "The expression you entered as the event property setting produced the following error: The expression you entered has a function name that Microsoft Access can't find.".

Thanks!
J2015Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
do you have a VBA function called HandleButton(var as string)  written either in the form's module or in a regular module

function  HandleButton(var as string) 
'codes here

end function

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
J2015Author Commented:
No, I had a Sub, and that's why it would not work!!!

In order to work, it needs to be a function, even if it returns nothing.

Thank you so much!
0
J2015Author Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for J2015's comment #a40864827

for the following reason:

My comment was a paraphrase.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

J2015Author Commented:
Now, what would be really cool is if the buttons could reference themselves, something like "=HandleButton(name)". This syntax returns the name of the form the control resides in, not the name of the control.

Is there a way for the the control to automatically return it's own name?
0
Rey Obrero (Capricorn1)Commented:
are you sure you want to accept your own post as the solution?
0
J2015Author Commented:
SouthMod/Capricorn1:

Sorry... I was not aware of the website's protocol. Now I understand why it's important to select the Expert's answer(s) as the solution: 1) to enable them to get points for their answers, 2) to buildup a knowledgebase of quality answers to questions.

Now, because Capricor1's initial answer triggered a corollary question (see comment ID: 40864849) I will wait before making a selection of a unique or multiple solutions. Therefore, this question remains open for now, unless that would break another rule.

J2015
0
J2015Author Commented:
I will post another question regarding "controls referencing themselves".
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.