Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Calculating option buttons on a Word 2007 form
I posted this to the wrong discussion group earlier....I'm using Word 2007
to create an on-line locked form. There are several questions on the form. Each question has 5 answers to choose from, for which I'm using Option Buttons. I want OptionButton 1's value to =1, OptionButton2=2, OptionButton3=3, etc. At the end of each question, Id like to display the value of the option button chosen. Then, at the very end, I'd like to use a text box where I would like to display the total value of all the OptionButtons selected. (ie. If there are 5 questions, Option button 4 chosen for each question; the final text box would display 20). Can this be done? If so, how do I begin? Thanks in advance! Tina |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Calculating option buttons on a Word 2007 form
Put a TextInput FormField at the end of each question and use the following
code in the ThisDocument object for the document in the Visual Basic Editor Private Sub OptionButton1_Click() If OptionButton1.Value = True Then ActiveDocument.FormFields("Question1").Result = 1 End If ActiveDocument.Fields.Update End Sub Private Sub OptionButton2_Click() If OptionButton2.Value = True Then ActiveDocument.FormFields("Question1").Result = 2 End If ActiveDocument.Fields.Update End Sub Private Sub OptionButton3_Click() If OptionButton3.Value = True Then ActiveDocument.FormFields("Question1").Result = 3 End If ActiveDocument.Fields.Update End Sub Private Sub OptionButton4_Click() If OptionButton4.Value = True Then ActiveDocument.FormFields("Question1").Result = 4 End If ActiveDocument.Fields.Update End Sub Private Sub OptionButton5_Click() If OptionButton5.Value = True Then ActiveDocument.FormFields("Question1").Result = 5 End If ActiveDocument.Fields.Update End Sub That will cause the number corresponding to the OptionButton that has its value set to True to be displayed in the formfield "Question1" Do the same thing for your other questions Finally, have a TextInput Formfield that you set to a Calculation type and in which you set the Expression to be = Question1 + Question2 + Question3 + etc. to hold the result. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "TinaR" wrote in message ... I posted this to the wrong discussion group earlier....I'm using Word 2007 to create an on-line locked form. There are several questions on the form. Each question has 5 answers to choose from, for which I'm using Option Buttons. I want OptionButton 1's value to =1, OptionButton2=2, OptionButton3=3, etc. At the end of each question, Id like to display the value of the option button chosen. Then, at the very end, I'd like to use a text box where I would like to display the total value of all the OptionButtons selected. (ie. If there are 5 questions, Option button 4 chosen for each question; the final text box would display 20). Can this be done? If so, how do I begin? Thanks in advance! Tina |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Calculating option buttons on a Word 2007 form
Doug,
This works like a charm!! Thank you so much!! TinaR "Doug Robbins - Word MVP" wrote: Put a TextInput FormField at the end of each question and use the following code in the ThisDocument object for the document in the Visual Basic Editor Private Sub OptionButton1_Click() If OptionButton1.Value = True Then ActiveDocument.FormFields("Question1").Result = 1 End If ActiveDocument.Fields.Update End Sub Private Sub OptionButton2_Click() If OptionButton2.Value = True Then ActiveDocument.FormFields("Question1").Result = 2 End If ActiveDocument.Fields.Update End Sub Private Sub OptionButton3_Click() If OptionButton3.Value = True Then ActiveDocument.FormFields("Question1").Result = 3 End If ActiveDocument.Fields.Update End Sub Private Sub OptionButton4_Click() If OptionButton4.Value = True Then ActiveDocument.FormFields("Question1").Result = 4 End If ActiveDocument.Fields.Update End Sub Private Sub OptionButton5_Click() If OptionButton5.Value = True Then ActiveDocument.FormFields("Question1").Result = 5 End If ActiveDocument.Fields.Update End Sub That will cause the number corresponding to the OptionButton that has its value set to True to be displayed in the formfield "Question1" Do the same thing for your other questions Finally, have a TextInput Formfield that you set to a Calculation type and in which you set the Expression to be = Question1 + Question2 + Question3 + etc. to hold the result. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "TinaR" wrote in message ... I posted this to the wrong discussion group earlier....I'm using Word 2007 to create an on-line locked form. There are several questions on the form. Each question has 5 answers to choose from, for which I'm using Option Buttons. I want OptionButton 1's value to =1, OptionButton2=2, OptionButton3=3, etc. At the end of each question, Id like to display the value of the option button chosen. Then, at the very end, I'd like to use a text box where I would like to display the total value of all the OptionButtons selected. (ie. If there are 5 questions, Option button 4 chosen for each question; the final text box would display 20). Can this be done? If so, how do I begin? Thanks in advance! Tina |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
calculating form fields in word 2007 | Tables | |||
Refresh Form option buttons | Microsoft Word Help | |||
How do I put radio (option) buttons into a form in Word? | Microsoft Word Help | |||
Using option buttons in Word form | Microsoft Word Help | |||
Using option buttons in Word form | Microsoft Word Help |