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

Checkboxes and Option Groups

P: n/a
How can the label for a checkbox and the labels for the options in an option
group be addressed? When a checkbox gets the focus, Access draws a dotted
box around the label. When an option group gets the focus, Access draws a
dotted box around the label of the first option or the label of the option
previously selected. I would like to change the backcolor of these labels to
yellow as the controls get focus.

For textboxes and comboboxes I have a function with the following code:
Function HiLiteControl()
Screen.ActiveControl.Backcolor = "8454143"
End Function

And I put the following in the GotFocus event of all the textboxes and
comboboxes:
=HiLiteControl()

I would like to be able to do something similar for the label for a checkbox
and the labels for the options in an option group.

Thanks!

Steve
Nov 13 '05 #1
Share this Question
Share on Google+
20 Replies


P: n/a
Br
PC Datasheet wrote:
How can the label for a checkbox and the labels for the options in an
option group be addressed? When a checkbox gets the focus, Access
draws a dotted box around the label. When an option group gets the
focus, Access draws a dotted box around the label of the first option
or the label of the option previously selected. I would like to
change the backcolor of these labels to yellow as the controls get
focus.
For textboxes and comboboxes I have a function with the following
code: Function HiLiteControl()
Screen.ActiveControl.Backcolor = "8454143"
End Function

And I put the following in the GotFocus event of all the textboxes and
comboboxes:
=HiLiteControl()

I would like to be able to do something similar for the label for a
checkbox and the labels for the options in an option group.

Thanks!

Steve


I'd pass the control name to your function on each control's OnFocus
event. If it's an option group or something just pass the label's name
instead of the control?

eg. (something like this....)

Private Function HiLiteControl(pMyControl as Control)
pMyControl.BackColor = "8454143"
End Function

Private Sub txtMyTextBox_OnFocus()
HiLiteControl Me![txtMyTextBox]
End Sub

Their's probably a dozen ways of achieving this.

Also, how are you resetting the color when the control looses the focus?
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #2

P: n/a
rkc
PC Datasheet wrote:
How can the label for a checkbox and the labels for the options in an option
group be addressed? When a checkbox gets the focus, Access draws a dotted
box around the label. When an option group gets the focus, Access draws a
dotted box around the label of the first option or the label of the option
previously selected. I would like to change the backcolor of these labels to
yellow as the controls get focus.

For textboxes and comboboxes I have a function with the following code:
Function HiLiteControl()
Screen.ActiveControl.Backcolor = "8454143"
End Function

And I put the following in the GotFocus event of all the textboxes and
comboboxes:
=HiLiteControl()

I would like to be able to do something similar for the label for a checkbox
and the labels for the options in an option group.


With checkboxes you can use Screen.ActiveControl.Controls(0).
The attached label is a 'child' of the combobox.

With Option Groups it's not so easy because the active control is the
Frame the option buttons are contained by.

Using Screen.ActiveControl in the LostFocus event to reset the
background is a runtime error waiting to happen. Clicking outside
the current form is one way to increase the odds of throwing an error.

Take Br@dley's advice. Ditch Screen.ActiveControl and write a function
that takes a control as an argument.

I'll wave my fee.


Nov 13 '05 #3

P: n/a
Bradley,

Thanks for responding!

I'm looking for a way to do something like screen.ActiveLabel so I can put
the same expression (=HiLiteLabel()) in the GotFocus event code line for all
the checkboxes and option groups.

I use the same process in the LostFocus event to reset the color using
backcolor of 16777215.

Steve
"Br@dley" <br*****@usenet.com> wrote in message
news:Kt*******************@news-server.bigpond.net.au...
PC Datasheet wrote:
How can the label for a checkbox and the labels for the options in an
option group be addressed? When a checkbox gets the focus, Access
draws a dotted box around the label. When an option group gets the
focus, Access draws a dotted box around the label of the first option
or the label of the option previously selected. I would like to
change the backcolor of these labels to yellow as the controls get
focus.
For textboxes and comboboxes I have a function with the following
code: Function HiLiteControl()
Screen.ActiveControl.Backcolor = "8454143"
End Function

And I put the following in the GotFocus event of all the textboxes and
comboboxes:
=HiLiteControl()

I would like to be able to do something similar for the label for a
checkbox and the labels for the options in an option group.

Thanks!

Steve


I'd pass the control name to your function on each control's OnFocus
event. If it's an option group or something just pass the label's name
instead of the control?

eg. (something like this....)

Private Function HiLiteControl(pMyControl as Control)
pMyControl.BackColor = "8454143"
End Function

Private Sub txtMyTextBox_OnFocus()
HiLiteControl Me![txtMyTextBox]
End Sub

Their's probably a dozen ways of achieving this.

Also, how are you resetting the color when the control looses the focus?
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response

Nov 13 '05 #4

P: n/a
Thanks for replying!

< Using Screen.ActiveControl in the LostFocus event to reset the background
is a runtime error waiting to happen. >
Why?

If I write a function that takes a control as an argument, I have to pass a
different control name at each call of the function. Is there a way to avoid
that. Screen.ActiveControl avoids that for textboxes and comboboxes and
that's why I use it. When I posted the question I was hoping to find
something like Screen.ActiveControl.Label.

Steve
"rkc" <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in message
news:7k*******************@twister.nyroc.rr.com...
PC Datasheet wrote:
How can the label for a checkbox and the labels for the options in an
option group be addressed? When a checkbox gets the focus, Access draws a
dotted box around the label. When an option group gets the focus, Access
draws a dotted box around the label of the first option or the label of
the option previously selected. I would like to change the backcolor of
these labels to yellow as the controls get focus.

For textboxes and comboboxes I have a function with the following code:
Function HiLiteControl()
Screen.ActiveControl.Backcolor = "8454143"
End Function

And I put the following in the GotFocus event of all the textboxes and
comboboxes:
=HiLiteControl()

I would like to be able to do something similar for the label for a
checkbox and the labels for the options in an option group.


With checkboxes you can use Screen.ActiveControl.Controls(0).
The attached label is a 'child' of the combobox.

With Option Groups it's not so easy because the active control is the
Frame the option buttons are contained by.

Using Screen.ActiveControl in the LostFocus event to reset the background
is a runtime error waiting to happen. Clicking outside
the current form is one way to increase the odds of throwing an error.

Take Br@dley's advice. Ditch Screen.ActiveControl and write a function
that takes a control as an argument.

I'll wave my fee.



Nov 13 '05 #5

P: n/a
I meant to previously ask ----

<With Option Groups it's not so easy ........>
Is it possible? How?

Thanks!

Steve
"rkc" <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in message
news:7k*******************@twister.nyroc.rr.com...
PC Datasheet wrote:
How can the label for a checkbox and the labels for the options in an
option group be addressed? When a checkbox gets the focus, Access draws a
dotted box around the label. When an option group gets the focus, Access
draws a dotted box around the label of the first option or the label of
the option previously selected. I would like to change the backcolor of
these labels to yellow as the controls get focus.

For textboxes and comboboxes I have a function with the following code:
Function HiLiteControl()
Screen.ActiveControl.Backcolor = "8454143"
End Function

And I put the following in the GotFocus event of all the textboxes and
comboboxes:
=HiLiteControl()

I would like to be able to do something similar for the label for a
checkbox and the labels for the options in an option group.


With checkboxes you can use Screen.ActiveControl.Controls(0).
The attached label is a 'child' of the combobox.

With Option Groups it's not so easy because the active control is the
Frame the option buttons are contained by.

Using Screen.ActiveControl in the LostFocus event to reset the background
is a runtime error waiting to happen. Clicking outside
the current form is one way to increase the odds of throwing an error.

Take Br@dley's advice. Ditch Screen.ActiveControl and write a function
that takes a control as an argument.

I'll wave my fee.



Nov 13 '05 #6

P: n/a
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote:
: PC Datasheet wrote:

<snip any substance>

: I'll wave my fee.

So it seems that you're not going to waive your fee -- otherwise
you'll have nothing to wave.

sorry, I couldn't resist such a good bad pun.
--thelma


Nov 13 '05 #7

P: n/a

"Thelma Lubkin" <th****@alpha2.csd.uwm.edu> wrote in message
news:di**********@uwm.edu...
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote:
: PC Datasheet wrote:

<snip any substance>

: I'll wave my fee.

So it seems that you're not going to waive your fee -- otherwise
you'll have nothing to wave.

sorry, I couldn't resist such a good bad pun.
--thelma

That's ok, PC always has a problem with spelling. He just does not have a
good dictionary.
(and forgets these newsgroups are for free help)

John... Visio MVP
Nov 13 '05 #8

P: n/a
Once again you demonstrate your intelligence! MVP must come in a crackerjack
box!

< I'll wave my fee.>
These were rkc's words not mine.

Is this why you have tried to reverse what you said 6 times in the last few
days.

Checkmate!

You lose.

BTW, did you ever look up metaphor?

Steve

"John Marshall, MVP" <la******@stonehenge.ca> wrote in message
news:ex**************@TK2MSFTNGP12.phx.gbl...

"Thelma Lubkin" <th****@alpha2.csd.uwm.edu> wrote in message
news:di**********@uwm.edu...
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote:
: PC Datasheet wrote:

<snip any substance>

: I'll wave my fee.

So it seems that you're not going to waive your fee -- otherwise
you'll have nothing to wave.

sorry, I couldn't resist such a good bad pun.
--thelma

That's ok, PC always has a problem with spelling. He just does not have a
good dictionary.
(and forgets these newsgroups are for free help)

John... Visio MVP

Nov 13 '05 #9

P: n/a
If you know what form all this is happening in, you should
use formobject.ActiveControl instead of the Screen object.
The Screen object covers too much territory.

I'm not convinced that I know where the focus is during the
LostFocus event, you may want to explore using the Exit
event instead.

The last item clicked on in an option group has the
OptionValue that matches the frame's Value.

Since label controls can not receive the focus, there is no
such thing as an active label. This means that the only
thing that knows an unattached label was clicked on is the
label's Click event procedure.

Clicking on an attached label moves the focus to the control
the label is attached to, so the label never gets involved.
As rkc said, you can get to the attached label using the
ActiveControl's Controls collection. All the control in an
option group are in the frame's Controls collection.
--
Marsh
MVP [MS Access]
PC Datasheet wrote:
< Using Screen.ActiveControl in the LostFocus event to reset the background
is a runtime error waiting to happen. >
Why?

If I write a function that takes a control as an argument, I have to pass a
different control name at each call of the function. Is there a way to avoid
that. Screen.ActiveControl avoids that for textboxes and comboboxes and
that's why I use it. When I posted the question I was hoping to find
something like Screen.ActiveControl.Label.
"rkc" wrote
PC Datasheet wrote:
How can the label for a checkbox and the labels for the options in an
option group be addressed? When a checkbox gets the focus, Access draws a
dotted box around the label. When an option group gets the focus, Access
draws a dotted box around the label of the first option or the label of
the option previously selected. I would like to change the backcolor of
these labels to yellow as the controls get focus.

For textboxes and comboboxes I have a function with the following code:
Function HiLiteControl()
Screen.ActiveControl.Backcolor = "8454143"
End Function

And I put the following in the GotFocus event of all the textboxes and
comboboxes:
=HiLiteControl()

I would like to be able to do something similar for the label for a
checkbox and the labels for the options in an option group.


With checkboxes you can use Screen.ActiveControl.Controls(0).
The attached label is a 'child' of the combobox.

With Option Groups it's not so easy because the active control is the
Frame the option buttons are contained by.

Using Screen.ActiveControl in the LostFocus event to reset the background
is a runtime error waiting to happen. Clicking outside
the current form is one way to increase the odds of throwing an error.

Take Br@dley's advice. Ditch Screen.ActiveControl and write a function
that takes a control as an argument.


Nov 13 '05 #10

P: n/a
Marsh,

Thanks for responding!

I'm trying to use the function across 7 forms so formobject won't work
unless there's a way to incorporate the ActiveForm property.

Your suggestion of using the Exit event sounds good!

Say an option group has three radio buttons and three associated labels. Are
the controls referenced Controls(0) to Controls(5)? And are they in the same
order as the options?

I know there's no such thing as Active.Label; I was just using that
expression as "pseudocode".

Steve
"Marshall Barton" <ma*********@wowway.com> wrote in message
news:5h********************************@4ax.com...
If you know what form all this is happening in, you should
use formobject.ActiveControl instead of the Screen object.
The Screen object covers too much territory.

I'm not convinced that I know where the focus is during the
LostFocus event, you may want to explore using the Exit
event instead.

The last item clicked on in an option group has the
OptionValue that matches the frame's Value.

Since label controls can not receive the focus, there is no
such thing as an active label. This means that the only
thing that knows an unattached label was clicked on is the
label's Click event procedure.

Clicking on an attached label moves the focus to the control
the label is attached to, so the label never gets involved.
As rkc said, you can get to the attached label using the
ActiveControl's Controls collection. All the control in an
option group are in the frame's Controls collection.
--
Marsh
MVP [MS Access]
PC Datasheet wrote:
< Using Screen.ActiveControl in the LostFocus event to reset the
background
is a runtime error waiting to happen. >
Why?

If I write a function that takes a control as an argument, I have to pass
a
different control name at each call of the function. Is there a way to
avoid
that. Screen.ActiveControl avoids that for textboxes and comboboxes and
that's why I use it. When I posted the question I was hoping to find
something like Screen.ActiveControl.Label.
"rkc" wrote
PC Datasheet wrote:
How can the label for a checkbox and the labels for the options in an
option group be addressed? When a checkbox gets the focus, Access draws
a
dotted box around the label. When an option group gets the focus,
Access
draws a dotted box around the label of the first option or the label of
the option previously selected. I would like to change the backcolor of
these labels to yellow as the controls get focus.

For textboxes and comboboxes I have a function with the following code:
Function HiLiteControl()
Screen.ActiveControl.Backcolor = "8454143"
End Function

And I put the following in the GotFocus event of all the textboxes and
comboboxes:
=HiLiteControl()

I would like to be able to do something similar for the label for a
checkbox and the labels for the options in an option group.

With checkboxes you can use Screen.ActiveControl.Controls(0).
The attached label is a 'child' of the combobox.

With Option Groups it's not so easy because the active control is the
Frame the option buttons are contained by.

Using Screen.ActiveControl in the LostFocus event to reset the
background
is a runtime error waiting to happen. Clicking outside
the current form is one way to increase the odds of throwing an error.

Take Br@dley's advice. Ditch Screen.ActiveControl and write a function
that takes a control as an argument.

Nov 13 '05 #11

P: n/a
Br
PC Datasheet wrote:
Thanks for replying!

< Using Screen.ActiveControl in the LostFocus event to reset the
background is a runtime error waiting to happen. >
Why?

If I write a function that takes a control as an argument, I have to
pass a different control name at each call of the function. Is there
a way to avoid that. Screen.ActiveControl avoids that for textboxes
and comboboxes and that's why I use it. When I posted the question I
was hoping to find something like Screen.ActiveControl.Label.

Steve
If you make an assumption that your label's name is the same as the
control's but perhaps with an "lbl" prefix, and you test to see the
current control type... you could then refence the label based on the
contorl name.
eg. Me!("lbl" & Me.ActiveControl.Name).BackColor = 1234

(Seems messy to me though)
"rkc" <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in message
news:7k*******************@twister.nyroc.rr.com...
PC Datasheet wrote:
How can the label for a checkbox and the labels for the options in
an option group be addressed? When a checkbox gets the focus,
Access draws a dotted box around the label. When an option group
gets the focus, Access draws a dotted box around the label of the
first option or the label of the option previously selected. I
would like to change the backcolor of these labels to yellow as the
controls get focus. For textboxes and comboboxes I have a function
with the following
code: Function HiLiteControl()
Screen.ActiveControl.Backcolor = "8454143"
End Function

And I put the following in the GotFocus event of all the textboxes
and comboboxes:
=HiLiteControl()

I would like to be able to do something similar for the label for a
checkbox and the labels for the options in an option group.


With checkboxes you can use Screen.ActiveControl.Controls(0).
The attached label is a 'child' of the combobox.

With Option Groups it's not so easy because the active control is the
Frame the option buttons are contained by.

Using Screen.ActiveControl in the LostFocus event to reset the
background is a runtime error waiting to happen. Clicking outside
the current form is one way to increase the odds of throwing an
error. Take Br@dley's advice. Ditch Screen.ActiveControl and write a
function that takes a control as an argument.

I'll wave my fee.


--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #12

P: n/a
rkc
Thelma Lubkin wrote:
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote:
: PC Datasheet wrote:

<snip any substance>

: I'll wave my fee.

So it seems that you're not going to waive your fee -- otherwise
you'll have nothing to wave.

sorry, I couldn't resist such a good bad pun.
--thelma


I actually appreciate you pointing that out and am further happy
that you found substance to snip.
Nov 13 '05 #13

P: n/a
rkc
PC Datasheet wrote:
I meant to previously ask ----

<With Option Groups it's not so easy ........>
Is it possible? How?


I'm sure it is. I just haven't woked it out yet because I
have never wanted to do it.

I think maybe Br@dley's suggestion of using naming conventions
might help. The problem I think you will run into is that the
Frame is the activecontrol even when one of it's contained
objects has the focus. I could be wrong.

I'll take a closer look after I finish trying to make a living
today. Hopefully you'll have a solution before then.
Nov 13 '05 #14

P: n/a
rkc
PC Datasheet wrote:
Marsh,

Thanks for responding!

I'm trying to use the function across 7 forms so formobject won't work
unless there's a way to incorporate the ActiveForm property.

Your suggestion of using the Exit event sounds good!

Say an option group has three radio buttons and three associated labels. Are
the controls referenced Controls(0) to Controls(5)? And are they in the same
order as the options?


All the controls contained in a Frame are members of the Frame's
controls collection. When first created they are ordered by the
order they were created in. Label first followed by the option button
it is attached to. I do not know if that can't be counted on not to
change during runtime, further editing of the form or the planets
being aligned in a certain way.
I'll wave goodbye to my fee.

Nov 13 '05 #15

P: n/a
You may want to use a Sub in each form's module to supply
the form object argument to the standard module procedure.
Otherwise, trust the Screen object and forge ahead.

The order of items in a frame's (or any other object's)
Controls collection) is undocumented (except the frame's
attached label, if it exists, should always be index 0, so
you should not count on it. You can loop through the
collection comparing the control type and option value.
Once you locate the "active" radio button, then use that
control's Controls collection to reference the label. Have
a play with this scenario, using Debug to see what other
controls are in each control's Controls collection. OTOH,
the option group control doesn't even have the Got/Lost
Focus or Enter/Exit events, so I don't really understand the
issue with this aspect the question.

My point about there being no such thing as an "ActiveLabel"
is that the concept is flawed and thinking about it that way
will lead you astray. You need to think in terms of the
active control and highlighting its attached label, if it
has on--
Marsh
MVP [MS Access]
PC Datasheet wrote:
I'm trying to use the function across 7 forms so formobject won't work
unless there's a way to incorporate the ActiveForm property.

Your suggestion of using the Exit event sounds good!

Say an option group has three radio buttons and three associated labels. Are
the controls referenced Controls(0) to Controls(5)? And are they in the same
order as the options?

I know there's no such thing as Active.Label; I was just using that
expression as "pseudocode".
"Marshall Barton" wrote
If you know what form all this is happening in, you should
use formobject.ActiveControl instead of the Screen object.
The Screen object covers too much territory.

I'm not convinced that I know where the focus is during the
LostFocus event, you may want to explore using the Exit
event instead.

The last item clicked on in an option group has the
OptionValue that matches the frame's Value.

Since label controls can not receive the focus, there is no
such thing as an active label. This means that the only
thing that knows an unattached label was clicked on is the
label's Click event procedure.

Clicking on an attached label moves the focus to the control
the label is attached to, so the label never gets involved.
As rkc said, you can get to the attached label using the
ActiveControl's Controls collection. All the control in an
option group are in the frame's Controls collection.

Nov 13 '05 #16

P: n/a

"PC Datasheet" <no****@nospam.spam> schreef in bericht news:KK******************@newsread2.news.atl.earth link.net...
I meant to previously ask ----

<With Option Groups it's not so easy ........>
Is it possible? How?

Thanks!

Steve


I did work out a very easy function to do just what you want.
The Function is called FormatOptionGroupLabels()
The function uses a naming-convention as Br@dley already suggested.

This is a generic function that uses Screen.ActiveForm.
You will need to use this function once after opening your form
(if you want the formatting for the chosen values at that time)
and/or you need to use the function on the AfterUpdate-event of your Option Groups.

If you are interested contact me and I will send you a screenshot.

Arno R
Nov 13 '05 #17

P: n/a
Thank you for responding!

I am interested. I would appreciate whatever you can send me.

Steve
"Arno R" <ar***********@tiscali.nl> wrote in message
news:43********************@dreader2.news.tiscali. nl...

"PC Datasheet" <no****@nospam.spam> schreef in bericht
news:KK******************@newsread2.news.atl.earth link.net...
I meant to previously ask ----

<With Option Groups it's not so easy ........>
Is it possible? How?

Thanks!

Steve


I did work out a very easy function to do just what you want.
The Function is called FormatOptionGroupLabels()
The function uses a naming-convention as Br@dley already suggested.

This is a generic function that uses Screen.ActiveForm.
You will need to use this function once after opening your form
(if you want the formatting for the chosen values at that time)
and/or you need to use the function on the AfterUpdate-event of your Option
Groups.

If you are interested contact me and I will send you a screenshot.

Arno R
Nov 13 '05 #18

P: n/a
I just did send the screenshot to you.
As I said in the mail: If you stop your advertising you can have the code for free !

Arno R
"PC Datasheet" <no****@nospam.spam> schreef in bericht news:Dv*****************@newsread1.news.atl.earthl ink.net...
Thank you for responding!

I am interested. I would appreciate whatever you can send me.

Steve


"Arno R" <ar***********@tiscali.nl> wrote in message
news:43********************@dreader2.news.tiscali. nl...

"PC Datasheet" <no****@nospam.spam> schreef in bericht
news:KK******************@newsread2.news.atl.earth link.net...
I meant to previously ask ----

<With Option Groups it's not so easy ........>
Is it possible? How?

Thanks!

Steve


I did work out a very easy function to do just what you want.
The Function is called FormatOptionGroupLabels()
The function uses a naming-convention as Br@dley already suggested.

This is a generic function that uses Screen.ActiveForm.
You will need to use this function once after opening your form
(if you want the formatting for the chosen values at that time)
and/or you need to use the function on the AfterUpdate-event of your Option
Groups.

If you are interested contact me and I will send you a screenshot.

Arno R

Nov 13 '05 #19

P: n/a

"Arno R" <ar***********@tiscali.nl> schreef in bericht news:43********************@dreader2.news.tiscali. nl...
I just did send the screenshot to you.
As I said in the mail: If you stop your advertising you can have the code for free !

Arno R

Since I don't here from you again, I guess your are not interested in free code or free support?

Arno R
Nov 13 '05 #20

P: n/a
"Arno R" <ar***********@tiscali.nl> schreef in bericht
news:43********************@dreader2.news.tiscali. nl...
I just did send the screenshot to you.
As I said in the mail: If you stop your advertising you can have the code
for free !

Since I don't hear from you again, I guess your are not interested in free
code or free support?

Arno R


Only if it makes him money.

John... Visio MVP
Nov 13 '05 #21

This discussion thread is closed

Replies have been disabled for this discussion.