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
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.
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...
< 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...
<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...
<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
< 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...
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
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...
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)
--
I actually appreciate you pointing that out and am further happy
that you found substance to snip.
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.
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.
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
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
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
"PC Datasheet" <nos...@nospam.spam> schreef in bericht news:DvU4f.15759$vw6...@newsread1.news.atl.earthlink.net...
Arno R
Since I don't here 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