Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

option buttons with same value

Status
Not open for further replies.

MykH

Technical User
Sep 18, 2001
8
0
0
US
newbie question:

does anyone know the easiest way to create option buttons with the same value (or a work around..?) i'm creating a customer response survey with "Yes/No/NA" option buttons. the values are set as 1/2/3, but I'd like "no/na" to have the same values as the questions are weighted and i'd like to total a score at the end :) Thx
 
Unfortunately you can't set the option values the same for two or more buttons; actually you can manually change the values of the respective option controls in design view, but this will 'link' the options together so that when you click one option of the set, all others with the same value will synchronise on the screen, which is probably not what you want.

Here's a simple workaround; I'll assume that the options are grouped with a frame called fraOptions, and the options have the assigned values of 1,2 and 3.

(a) Create a new unbound control on the form; call it txtOptionWeight

(b) You can bind it to a field in the underlying recordset if you like, and also give it a default value, consistent with the default associated with the option set.

(c) Add the following code to the after update event of the fraOptions control:

Private Sub fraOptions_AfterUpdate()
Dim F As Form: Set F = Me
Select Case F!fraOptions
Case 1
F!txtOptionWeight = 1 'change value as reqd
Case 2
F!txtOptionWeight = 2 'change value as reqd
Case 3
F!txtOptionWeight = 1 'change value as reqd
End Select
End Sub

(d) If you set the visible property of this control to False, then it will be transparent to the user, but will hold the weighting value that you want to use.

Hope this helps,

Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
Sgn(OptionGroupName-1) will return the value 0 for option 1 and value 1 for all other options.

Hope this helps

Dan
 
Thanks for the info. I tried the steps mentioned by Steve and they work perfectly!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top