Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
TinaR TinaR is offline
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
TinaR TinaR is offline
external usenet poster
 
Posts: 2
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
calculating form fields in word 2007 noviceword07 Tables 8 January 30th 09 12:19 AM
Refresh Form option buttons Susan Microsoft Word Help 1 February 17th 06 12:40 AM
How do I put radio (option) buttons into a form in Word? Ellymoo Microsoft Word Help 3 October 26th 05 07:02 PM
Using option buttons in Word form Lisa Microsoft Word Help 1 May 17th 05 06:50 PM
Using option buttons in Word form Cindy Microsoft Word Help 0 May 17th 05 06:22 PM


All times are GMT +1. The time now is 06:20 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"