Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Checkboxes and Option Groups

5 views
Skip to first unread message

PC Datasheet

unread,
Oct 16, 2005, 6:56:14 PM10/16/05
to
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


Br@dley

unread,
Oct 16, 2005, 7:36:10 PM10/16/05
to

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


rkc

unread,
Oct 16, 2005, 9:42:27 PM10/16/05
to

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.


PC Datasheet

unread,
Oct 16, 2005, 9:58:31 PM10/16/05
to
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" <bra...@usenet.com> wrote in message
news:KtB4f.19693$U51....@news-server.bigpond.net.au...

PC Datasheet

unread,
Oct 16, 2005, 10:07:46 PM10/16/05
to
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" <r...@rochester.yabba.dabba.do.rr.bomb> wrote in message
news:7kD4f.50636$Xl2....@twister.nyroc.rr.com...

PC Datasheet

unread,
Oct 16, 2005, 10:10:50 PM10/16/05
to
I meant to previously ask ----

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

Thanks!

Steve


"rkc" <r...@rochester.yabba.dabba.do.rr.bomb> wrote in message
news:7kD4f.50636$Xl2....@twister.nyroc.rr.com...

Thelma Lubkin

unread,
Oct 16, 2005, 10:10:58 PM10/16/05
to
rkc <r...@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


John Marshall, MVP

unread,
Oct 16, 2005, 10:47:29 PM10/16/05
to

"Thelma Lubkin" <the...@alpha2.csd.uwm.edu> wrote in message
news:div17i$nim$1...@uwm.edu...


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


PC Datasheet

unread,
Oct 16, 2005, 11:09:44 PM10/16/05
to
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" <lanc...@stonehenge.ca> wrote in message
news:exhddUs0...@TK2MSFTNGP12.phx.gbl...

Marshall Barton

unread,
Oct 17, 2005, 2:25:15 AM10/17/05
to
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

unread,
Oct 17, 2005, 2:39:37 AM10/17/05
to
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" <marsh...@wowway.com> wrote in message
news:5hf6l19u5a50nopjp...@4ax.com...

Br@dley

unread,
Oct 17, 2005, 3:01:28 AM10/17/05
to
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

unread,
Oct 17, 2005, 7:03:58 AM10/17/05
to

I actually appreciate you pointing that out and am further happy
that you found substance to snip.

rkc

unread,
Oct 17, 2005, 7:11:27 AM10/17/05
to
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.

rkc

unread,
Oct 17, 2005, 7:30:00 AM10/17/05
to
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.

Marshall Barton

unread,
Oct 17, 2005, 2:05:33 PM10/17/05
to
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

Arno R

unread,
Oct 17, 2005, 4:17:00 PM10/17/05
to

"PC Datasheet" <nos...@nospam.spam> schreef in bericht news:KKD4f.15995$QE1....@newsread2.news.atl.earthlink.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

PC Datasheet

unread,
Oct 17, 2005, 5:15:15 PM10/17/05
to
Thank you for responding!

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

Steve


"Arno R" <arraNO...@tiscali.nl> wrote in message
news:43540700$0$728$5fc...@dreader2.news.tiscali.nl...

Arno R

unread,
Oct 17, 2005, 5:47:50 PM10/17/05
to
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" <nos...@nospam.spam> schreef in bericht news:DvU4f.15759$vw6...@newsread1.news.atl.earthlink.net...

Arno R

unread,
Oct 19, 2005, 9:04:46 AM10/19/05
to

"Arno R" <arraNO...@tiscali.nl> schreef in bericht news:43541c27$0$714$5fc...@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

John Marshall, MVP

unread,
Oct 19, 2005, 10:07:18 AM10/19/05
to
"Arno R" <arraNO...@tiscali.nl> schreef in bericht
news:43541c27$0$714$5fc...@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


0 new messages