Exposing the optionValue of an optionbutton

M

Marcel K.

I am trying to determine in code the value Option Value of
each control in an option frame controls collection. The
intent is to find a match to Frame.value then get the tag
value of the the option button selected. The tag has some
important information relative to the selection. AM I
close here:

Private Sub Current_Status_ID()
Dim ctl As Control
Dim varFraStatusValue As Variant
Dim varCtlOptionValue As Variant

For Each ctl In fraStatus.Controls
varFraStatusValue = fraStatus.Value
varCtlOptionValue = ctl.OptionValue

If varCtlOptionValue = varFraStatusValue Then
strCurrent_Selected_Status = Val(ctl.Tag)

'This is to get the tag value here?

End If

Next

End Sub

Regards,

Marcel K.
 
T

TC

Your code looks ok to me, from a quick look.

Here's another approach. Name the option group controls in some predictable
way, depending on their OptionValues. Say opt1, opt2, opt3 and so on.

Then just do this (untested):

strCurrent_Selected_Status = _
me![fraStatus].controls("opt" & me![fraStatus].Value).tag

You do not need the '.Value', I just put it there for clarity. Obviously you
might want to use a naming prefix better than "opt". Perhaps "optStatus"?

HTH,
TC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top