Option group value in an unbound text box.

D

dsc2bjn

I would like to create an option group with several checkboxes which
populates a "text value" into an unbound text box on the same form.

I created the option group and the unbound text box. I have tried creating
IIf statements in the AfterUpdate Event for the option group, but can't
figure out how to make it update the text box. The only thing that shows in
the text box is #error
 
U

UpRider

In the below event procedure, the unbound textboxes are txtBox1 and txtBox2.
The option buttons in the opton group have an option value in their data
property sheet. This value is duplicated in
the group's value when each button is selected.

Private Sub grpSelector_AfterUpdate()
Select Case grpSelector.Value
Case 1
Me.txtBox1 = "Option 1 selected"
Me.txtBox2 = ""
Case 2
Me.txtBox2 = "Option 2 selected"
Me.txtBox1 = ""
End Select
End Sub

HTH, UpRider
 
D

dsc2bjn

Note exactly what I am looking for...

I want to pass the numeric value of the item selected in the option group to
an unbound text box. Only 1 text box on the form. I will use that unbound
text box value to pass to the next form (after I use the IIf to convert the
number into a text value.

It would be kind of like using a drop down menu, except the client doesn't
want a drop down. They are afraid someone will pick the wrong value from a
drop down, so an option group using check boxes was my thought.
 
U

UpRider

OK, equate the value of the unbound textbox to the option group value.

Private Sub grpSelector_AfterUpdate()
Me.txtBox1 = grpSelector.Value
End Sub

UpRider
 
D

dsc2bjn

Thanks!!!

It was a little different, but I figured it out based upon what you wrote.

Instead of grpSelector it turned out to be the AfterUpdate() on the "Frame".
In my case Frame27 was what the wizard created, when I set up the
OptionGroup.

I have seven check boxes. The "IIf" statement to convert from number to Text
is long, but it does work.

Thanks again!!
 
J

John W. Vinson

Note exactly what I am looking for...

I want to pass the numeric value of the item selected in the option group to
an unbound text box. Only 1 text box on the form. I will use that unbound
text box value to pass to the next form (after I use the IIf to convert the
number into a text value.

It would be kind of like using a drop down menu, except the client doesn't
want a drop down. They are afraid someone will pick the wrong value from a
drop down, so an option group using check boxes was my thought.

You're going all around the barn to do something simple!

The Option Group control *itself* has a numeric value; there's no need to copy
that number into another table.

And an IIF() statement is ok for two or maybe three values, but for more, use
Choose() instead:

Choose(Me!optMyOptionGroup, "Rudolph", "Dasher", "Dancer", "Vixen", ...)

for values 1, 2, 3, 4, ...

Or... better... have a table with the number to text translation and just use
the option group as a search criterion.

John W. Vinson [MVP]
 

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