help in caluclation option buttons values - word 2007

tarek_ta2ta2

Tarek
Local time
Yesterday, 17:45
Joined
Jun 8, 2008
Messages
47
I have a section on a form that has 4 questions, numbered 1-4, with 4 option buttons per question. Each of the option buttons have the same response (bad, normal, good, excellent), and each answer is given a point value for each question.

bad give 1, normal give 2, good give 3, excellent give4

For instance, question 1 might ask "trip evaluation?" and if you answer bad you will get +1, normal will earn you +2, and so on.

I would like to total the points for all the four questions in visible textbox at the end of the 4 questions.

i use this code but it works for only one question can't calculate the total for the four questions


Private Sub test_Click()
Dim total As Integer
Dim QNUM As Integer
QNUM = QNUM + 1
total = 0
Select Case QNUM
Case 1
If bad1.Value = True Then total = total + 1
If normal1.Value = True Then total = total + 2
If good1.Value = True Then total = total + 3
If Excellent1 = True Then total = total + 4
MsgBox "your total is: " & total

End Select

End Sub
 
You need to create the code seperately for EACH question! Try This....

Code:
Dim Total as integer
Dim Q1 as integer
Dim Q2 as integer
Dim Q3 as integer
 
Total = 0
 
select case true
     case optQ1Bad.value=true '<--------Bad
          Q1=1
     case optQ1Normal.value=true '<--------Normal
          Q1=2
     case optQ1Good.value=true '<--------Good
          Q1=3
     case optQ1Excellent.value=true '<--------Excellent
          Q1=4
end select
 
select case true
     case optQ2Bad.value=true '<--------Bad
          Q2=1
     case optQ2Normal.value=true '<--------Normal
          Q2=2
     case optQ2Good.value=true '<--------Good
          Q2=3
     case optQ2Excellent.value=true '<--------Excellent
          Q2=4
end select
 
select case true
     case optQ3Bad.value=true '<--------Bad
          Q3=1
     case optQ3Normal.value=true '<--------Normal
          Q3=2
     case optQ3Good.value=true '<--------Good
          Q3=3
     case optQ3Excellent.value=true '<--------Excellent
          Q2=4
end select
 
Total = Q1+Q2+Q3

It's a VBA thing... I really wish it supported Control Arrays.
Hope this helps.
 
And I'm assuming you used QNum as the Question number right????
Your Select Case statement as it stands will only allow it to calculate if QNUM=1
 

Users who are viewing this thread

Back
Top Bottom