Which object called a function

G

Goldar

I have 5 radio buttons that all call the same function in response to an
"after update" condition. How can this function tell which button called it.
My form contains 4 tabs, the second of which contains the option buttons. I
tried using the following code but I keep getting an error:
Set uiObj = Screen.ActiveControl ' this gives me the error
objectName = UCase(ui.Name)
The error that I get is: "The expression After Update you entered as the
event property setting The expression you entered required the control to be
in the active window"
 
J

Jeanette Cunningham

If you put your 5 radio buttons in an option group or frame, you can use its
built-in feature.
Each radio button has a value and when a radio button is clicked, the whole
option group
is given the value of the button that was clicked.

If user clicks button 4, the option group has a value equal to 4.

So your code can go
Select Case Me.[NameOfOptionGroup]
Case 1
'code to do something for this case

Case 2
'code to do something for this case

.....and so on till you end with End Select


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
G

Goldar

Thank you very much for a simple alternative to my implementation. I'm still
not sure of what the error I received meant, but your recommendation is much
better.

Jeanette Cunningham said:
If you put your 5 radio buttons in an option group or frame, you can use its
built-in feature.
Each radio button has a value and when a radio button is clicked, the whole
option group
is given the value of the button that was clicked.

If user clicks button 4, the option group has a value equal to 4.

So your code can go
Select Case Me.[NameOfOptionGroup]
Case 1
'code to do something for this case

Case 2
'code to do something for this case

.....and so on till you end with End Select


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



Goldar said:
I have 5 radio buttons that all call the same function in response to an
"after update" condition. How can this function tell which button called
it.
My form contains 4 tabs, the second of which contains the option buttons.
I
tried using the following code but I keep getting an error:
Set uiObj = Screen.ActiveControl ' this gives me the error
objectName = UCase(ui.Name)
The error that I get is: "The expression After Update you entered as the
event property setting The expression you entered required the control to
be
in the active window"


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top