Setting option button values

R

Resh :0)

Hi,

Just wondering if anyone was able to help me....

I've produced a report where there are four option buttons...

Named

Purple
Orange
Red
Double Red

I used wizard, and so it set the values as 1,2,3,4 respectively...

but when i create a report to pull the information stored on the
form/table... the field in the report just holds one of the 1,2,3,4 option
values, where as i want it to show, Purple, Orange, Red....

I've checked on the help menu, and all it says is that the option value has
to be a number....

Does anyone have a clue about how to get around this?

Thanks :0)
 
L

Lynn Trapp

Add an unbound textbox (txtDisplayColor) to your report and, then, write a
case statement in the format event of your Report's Detail section that
displays what you want.

Select Case optYourOptionGroup

Case 1
Me.txtDisplayColor = "Purple"
Case 2
Me.Me.txtDisplayColor = "Orange"
Case 3
Me.Me.txtDisplayColor = "Red"
Case 4
Me.Me.txtDisplayColor = "Double Red"
Case Else
Me.Me.txtDisplayColor = "No Color Selected"

End Select


--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html
 
K

kabaka

Well, you really ought to have searched for this subject before posting as it
would provide you with a much quicker answer (as I know this subject has been
discussed before).

There are several ways to do this that I've seen. One of which is using
Select Case statements. I have a function to do this that I use all the
time, although I'm sure there are more elegant solutions. You pass it the
optiongroup name and it returns the control name of the selected button (i.e.
you have to name each button "Red" , "Purple", etc.) It checks the controls
for type 105 (radio button). Depending on the type of control you use, you
may have to change the controltype value.

Function FindName(OptionGroup) As String
Dim j%, val%
val = OptionGroup.Value
For j = 0 To OptionGroup.Controls.count - 1
If OptionGroup.Controls.Item(j).ControlType = 105 Then
If OptionGroup.Controls.Item(j).OptionValue = val Then
FindName = OptionGroup.Controls.Item(j).name
End If
End If
Next j
End Function

Good Luck
 
R

Resh :0)

Hi,

I've tried your select case statement below... but i keep coming up with an
error... where it says...

Select Case... i've put OptionGroup (the name of the Option Group), is that
correct? as the error i keep coming up with is "variable not defined"...

thanks ;0)
 
R

Resh :0)

Thanks for the help so far.. but i found something on one of the other posts...

i put the following in the unbound text box and it works :0)

=Choose([Amends],"Purple","Orange","Red","Double Red")

Thanks
 
Top