As with anything else in VBA/Access there are several ways to accomplish
this. I always prefer to make the code as dynamic as possible so anytime I
can make the code figure it out without me altering it when I add new options
that's what I would do.
In that vain I would suggest that you add the Status ("AWOL" in your
example) to the Tag property of the Option Button when you add the control to
the Option Groug. Then you can simply loop through the Controls collection of
the Option Group looking for OptionButton controls. Test there OptionValue
property against that of the OptionGroup and then set the Caption of your
Status Label to the Tag property of the Option Button selected.
Here's an example:
Private Sub opgStatus_AfterUpdate()
Dim ctl As Control
For Each ctl In opgStatus.ControlsReference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6694Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6694
If TypeOf ctl Is OptionButton Then
If Me.opgStatus.Value = ctl.OptionValue Then
Me.lblStatus.Caption = ctl.Tag
Set ctl = Nothing
As you can see, you can now simply add OptionsButton's to the OptionGroup,
put the Status you want in the Tag property of the OptionButton and the code
will continue to work without modification.
This would work well (or even better) if you used a table of status' to
dynamically build the OptionGroup using the Status ID as the OptionValue. Of
course if you reach this point, a different control (such as a ListBox or
ComboBox) would probably work better.
If this answered your question please respond accordingly when asked. THis
will mark it as an answer and allow others to find it more easily.
"Last user''''s name that modified a reco" wrote:
> hi. greetings!
> i have an employee database and i have an option group called "Employee
> Status" and a label called lblStatus. Now, what I want to do is to display
> into the lblStatus the option I selected from the option group. For example,
> when I select "AWOL" from the option group, lblStatus should display "AWOL".
> Please help me.
> Thank you very much!