If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#11
|
|||
|
|||
Checkboxes and Option Groups
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" wrote in message ... 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. |
#12
|
|||
|
|||
Checkboxes and Option Groups
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" wrote in message ... 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 |
#13
|
|||
|
|||
Checkboxes and Option Groups
Thelma Lubkin wrote:
rkc 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. |
#14
|
|||
|
|||
Checkboxes and Option Groups
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. |
#15
|
|||
|
|||
Checkboxes and Option Groups
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. |
#16
|
|||
|
|||
Checkboxes and Option Groups
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. |
#17
|
|||
|
|||
Checkboxes and Option Groups
"PC Datasheet" schreef in bericht 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 |
#18
|
|||
|
|||
Checkboxes and Option Groups
Thank you for responding!
I am interested. I would appreciate whatever you can send me. Steve "Arno R" wrote in message . nl... "PC Datasheet" schreef in bericht 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 |
#19
|
|||
|
|||
Checkboxes and Option Groups
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" schreef in bericht news Thank you for responding! I am interested. I would appreciate whatever you can send me. Steve "Arno R" wrote in message . nl... "PC Datasheet" schreef in bericht 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 |
#20
|
|||
|
|||
Checkboxes and Option Groups
"Arno R" schreef in bericht . 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 |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
help with checkboxes... | Brook | Using Forms | 4 | September 8th, 2005 11:32 PM |
need help with problems using checkboxes | jkendrick75 | General Discussion | 1 | June 23rd, 2005 08:25 PM |
Checkboxes in Microsoft Word | awhit | Page Layout | 3 | May 3rd, 2005 08:01 PM |
Printing selected records according to marked checkboxes? | Leslie | New Users | 5 | April 2nd, 2005 01:11 AM |
ten checkboxes - how to allow only one to be selected | [email protected] | Using Forms | 4 | October 21st, 2004 01:45 PM |