By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,162 Members | 992 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,162 IT Pros & Developers. It's quick & easy.

Identifying what was clicked

P: n/a
Hey again -

I have a bunch of similar controls on a form (A2000), and I'm calling the
same code (with an argument as to what was clicked) when any one of them is
clicked. I'd like to generalize the code without having to modify EACH one
with a self-specific parameter in the call. That is, instead of calling...

called_when_clicked ("A1")

I just want to run:

called_when_clicked (my own control name)

....without the parentheses of course. Then I could use the same exact line
of code for all the controls, and decide what to do in the called routine
(table lookups built from the control name). I have tried using
ActiveControl, but since the controls themselves are on a tab page, all I
get is the name of the tab control. And of course, "Me" refers to the form
they're all on. Is there an equivalent for the control itself?

(What I'd REALLY like would be a way to use an object-oriented approach, and
have the CLASS of control defined to make this call automagically, without
having to create a separate event procedure for every one...)

Armando
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Armando wrote:
Hey again -

I have a bunch of similar controls on a form (A2000), and I'm calling the
same code (with an argument as to what was clicked) when any one of them is
clicked. I'd like to generalize the code without having to modify EACH one
with a self-specific parameter in the call. That is, instead of calling...

called_when_clicked ("A1")

I just want to run:

called_when_clicked (my own control name)

...without the parentheses of course. Then I could use the same exact line
of code for all the controls, and decide what to do in the called routine
(table lookups built from the control name). I have tried using
ActiveControl, but since the controls themselves are on a tab page, all I
get is the name of the tab control. And of course, "Me" refers to the form
they're all on. Is there an equivalent for the control itself?

(What I'd REALLY like would be a way to use an object-oriented approach, and
have the CLASS of control defined to make this call automagically, without
having to create a separate event procedure for every one...)

Armando

Check out the ActiveControl property in help. See also ActiveForm property.

Nov 13 '05 #2

P: n/a

"Salad" <oi*@vinegar.com> wrote in message
news:Sv****************@newsread2.news.pas.earthli nk.net...
Armando wrote:
Hey again -

I have a bunch of similar controls on a form (A2000), and I'm calling the same code (with an argument as to what was clicked) when any one of them is clicked. I'd like to generalize the code without having to modify EACH one with a self-specific parameter in the call. That is, instead of calling...
called_when_clicked ("A1")

I just want to run:

called_when_clicked (my own control name)

...without the parentheses of course. Then I could use the same exact line of code for all the controls, and decide what to do in the called routine (table lookups built from the control name). I have tried using
ActiveControl, but since the controls themselves are on a tab page, all I get is the name of the tab control. And of course, "Me" refers to the form they're all on. Is there an equivalent for the control itself?

(What I'd REALLY like would be a way to use an object-oriented approach, and have the CLASS of control defined to make this call automagically, without having to create a separate event procedure for every one...)

Armando

Check out the ActiveControl property in help. See also ActiveForm

property.


I always list the things I've tried before asking the group to help. That
way we save posts to read through, and makes it clear that I'm not out for a
free answer, but actually expended some effort first. It's my way of
showing appreciation for the help, beforehand.

Anyway, I did try ActiveControl - and I get the name of the Tab control. I
can't see into it any deeper, unless there's another command.
Nov 13 '05 #3

P: n/a
Armando wrote:
"Salad" <oi*@vinegar.com> wrote in message
news:Sv****************@newsread2.news.pas.earthli nk.net...
Armando wrote:

Hey again -

I have a bunch of similar controls on a form (A2000), and I'm calling
the
same code (with an argument as to what was clicked) when any one of them
is
clicked. I'd like to generalize the code without having to modify EACH
one
with a self-specific parameter in the call. That is, instead of
calling...
called_when_clicked ("A1")

I just want to run:

called_when_clicked (my own control name)

...without the parentheses of course. Then I could use the same exact
line
of code for all the controls, and decide what to do in the called
routine
(table lookups built from the control name). I have tried using
ActiveControl, but since the controls themselves are on a tab page, all
I
get is the name of the tab control. And of course, "Me" refers to the
form
they're all on. Is there an equivalent for the control itself?

(What I'd REALLY like would be a way to use an object-oriented approach,
and
have the CLASS of control defined to make this call automagically,
without
having to create a separate event procedure for every one...)

Armando


Check out the ActiveControl property in help. See also ActiveForm


property.
I always list the things I've tried before asking the group to help. That
way we save posts to read through, and makes it clear that I'm not out for a
free answer, but actually expended some effort first. It's my way of
showing appreciation for the help, beforehand.

Anyway, I did try ActiveControl - and I get the name of the Tab control. I
can't see into it any deeper, unless there's another command.

I have a table, Table1 with the fields Test1 and Test2. I created a
form and dropped a tab control onto it and then dropped Test1 and Test2
onto the Tab1.

Here is my code for Test1
Private Sub Test1_GotFocus()
MsgBox "Focus " & Screen.ActiveControl.Name
End Sub

Private Sub Test1_Click()
MsgBox "Clicked " & Screen.ActiveControl.Name
End Sub

Private Sub TabCtl0_Click()
MsgBox "Tab " & Screen.ActiveControl.Name
End Sub

WHen I run it, the message box say Test1 as I expected. I can set focus
to or click in Test1 and I get a message. I can click into Test2 and
click the tab control and Access echoes Test2. So...I'm sorry I can't
help you out with your problem. You might want to run a test like mine,
see if you get the same results.
Nov 13 '05 #4

P: n/a

"Salad" <oi*@vinegar.com> wrote in message
news:G6******************@newsread1.news.pas.earth link.net...
...
...
WHen I run it, the message box say Test1 as I expected. I can set focus
to or click in Test1 and I get a message. I can click into Test2 and
click the tab control and Access echoes Test2. So...I'm sorry I can't
help you out with your problem. You might want to run a test like mine,
see if you get the same results.


Thanks for the second reply - I'll play with it some more.

Armando
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.