PDA

View Full Version : Solved: Multiple option buttons on user form



jwise
08-26-2008, 07:07 AM
Hi,

I'm essentially doing a userform for inputting survey responses. There are 4 yes/no questions. Some people will not answer certain questions, so there are actually three responses: Y/N/No Answer. I have used option buttons for these 12 fields.

The problem is that you can only click one field and not one per question. How do I divide these 12 option buttons so that I can get 4 responses? This has probably been asked somewhere, but I couldn't find it on VBAX or Google.

TIA

Bob Phillips
08-26-2008, 07:55 AM
Set the GroupName property of like buttons.

jwise
08-26-2008, 09:27 AM
Thanks again for your solution. I just don't do a very good job on these searches.

jwise
08-28-2008, 09:18 AM
The GROUPNAME worked great, making the user select one of the three choices (Yes-No-No Answer). The problem is that it does not require all 4 questions to be answered, i.e. when you input the survey, you can only select one of the three choices, but you can altogether skip a question.

I must require one of the three answers for each of the four questions. How do I do this? I'm guessing that there is an event where I can count the number of selections made before my "command process" button is clicked where I update the worksheet with the additional data.

TIA

Bob Phillips
08-28-2008, 10:14 AM
I think you have to count them



Private Sub cmdOK_Click()
If (optGroup11.Value + optGroup12.Value + optGroup13.Value) = 0 Or _
(optGroup21.Value + optGroup22.Value + optGroup23.Value) = 0 Then

MsgBox "incomplete"
Else

Me.Hide
End If
End Sub

jwise
08-29-2008, 07:12 AM
Thanks again...

I had no idea about the 0 value. I'm surprised that this will work because of the very likely possibility that the Boolean True/False has been set in the value (the usual case).

I understand that normally a 0 or 1 means true or false, I'm just surprised that one can use this same field as a numeric.

Thanks again.

Bob Phillips
08-29-2008, 07:20 AM
When you do math on TRUE/FALSE, it resolves to a numeric value.

jwise
09-01-2008, 02:09 PM
Thanks again. This is working great.

grichey
09-01-2008, 02:53 PM
These aren't resolving true / false are they? They're resolving as the number of the option, right? So they're resolvign as 1 , 2 , or 3. (or 0 for nothing selected)