Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.tables
|
|||
|
|||
Setting a value to a option button & then calculating the total
I am using MS Word 2003 to create a Word document form.
I'm using tables to insert my form fields. In one table I have option buttons where the user must select one of the option buttons in that group. For example: My first Option button group would be named "Adaptability". Within the "Adaptability" Option button Group I have 4 option buttons: Ineffective, Capable, Superior and N/A. I have 10 Groups with each group having 4 options, Ineffective, Capable, Superior and N/A. Ineffective should have a checked value of 1, Capable should have a checked value of 2, Superior should have a checked value of 3 and N/A should have a checked value of -1. I want to write something in code to check the value of each groups option buttons and then present a total that will be divided by 10. I hope I've given you the info you need to help me out, but if not, please let me know and I'll try to explain further. Sometimes it is difficult to convey what you want in writing. I'm pretty much of a novice at this so can anyone help me out? I think that I need some kind of CASE statement, but not sure. Thanks very much in advance. |
#3
Posted to microsoft.public.word.tables
|
|||
|
|||
Setting a value to a option button & then calculating the total
Greg:
Thank you for the quick response. If I wanted pScore to show up in a form field called "Total Score" how would I do that:? Greg Maxey wrote: Something like this should work: Sub Eval() Dim a, b, c, d, e, f, g, h, i, j As Long Dim pScore As Long With ThisDocument Select Case True 'First group Case .OptionButton1.Value a = 3 Case .OptionButton2.Value a = 2 Case .OptionButton3.Value a = 1 Case .OptionButton4.Value a = -1 Case Else MsgBox "No selection in Group 1" End Select Select Case True 'First group Case .OptionButton5.Value b = 3 Case .OptionButton6.Value b = 2 Case .OptionButton7.Value b = 1 Case .OptionButton8.Value b = -1 Case Else MsgBox "No selection in Group 2" End Select 'Repeat for groups 3 through 10 pScore = (a + b) / 2 'Test formula. Delete when you have create the other groups 'pScore = (a + b + c + d + e + f + g + h + i + j) / 10 'Real formula. MsgBox "Average score = " & pScore End With End Sub wrote: I am using MS Word 2003 to create a Word document form. I'm using tables to insert my form fields. In one table I have option buttons where the user must select one of the option buttons in that group. For example: My first Option button group would be named "Adaptability". Within the "Adaptability" Option button Group I have 4 option buttons: Ineffective, Capable, Superior and N/A. I have 10 Groups with each group having 4 options, Ineffective, Capable, Superior and N/A. Ineffective should have a checked value of 1, Capable should have a checked value of 2, Superior should have a checked value of 3 and N/A should have a checked value of -1. I want to write something in code to check the value of each groups option buttons and then present a total that will be divided by 10. I hope I've given you the info you need to help me out, but if not, please let me know and I'll try to explain further. Sometimes it is difficult to convey what you want in writing. I'm pretty much of a novice at this so can anyone help me out? I think that I need some kind of CASE statement, but not sure. Thanks very much in advance. |
#4
Posted to microsoft.public.word.tables
|
|||
|
|||
Setting a value to a option button & then calculating the total
Greg:
Also, I put your code in as shown below, but it doesn't seem to be calculating the total correctly. If "Ineffective" is = 1 and "Capable" is equal to 2 then the total would be 3 / 2 which would be 1.5 and I think it is rounding up. I don't want it to do that. Thanks, again! wrote: I am using MS Word 2003 to create a Word document form. I'm using tables to insert my form fields. In one table I have option buttons where the user must select one of the option buttons in that group. For example: My first Option button group would be named "Adaptability". Within the "Adaptability" Option button Group I have 4 option buttons: Ineffective, Capable, Superior and N/A. I have 10 Groups with each group having 4 options, Ineffective, Capable, Superior and N/A. Ineffective should have a checked value of 1, Capable should have a checked value of 2, Superior should have a checked value of 3 and N/A should have a checked value of -1. I want to write something in code to check the value of each groups option buttons and then present a total that will be divided by 10. I hope I've given you the info you need to help me out, but if not, please let me know and I'll try to explain further. Sometimes it is difficult to convey what you want in writing. I'm pretty much of a novice at this so can anyone help me out? I think that I need some kind of CASE statement, but not sure. Thanks very much in advance. |
#5
Posted to microsoft.public.word.tables
|
|||
|
|||
Setting a value to a option button & then calculating the total
Yes sorry.
Change the declaration of a, b, c, etc. and pScore to Double vice Long wrote: Greg: Also, I put your code in as shown below, but it doesn't seem to be calculating the total correctly. If "Ineffective" is = 1 and "Capable" is equal to 2 then the total would be 3 / 2 which would be 1.5 and I think it is rounding up. I don't want it to do that. Thanks, again! wrote: I am using MS Word 2003 to create a Word document form. I'm using tables to insert my form fields. In one table I have option buttons where the user must select one of the option buttons in that group. For example: My first Option button group would be named "Adaptability". Within the "Adaptability" Option button Group I have 4 option buttons: Ineffective, Capable, Superior and N/A. I have 10 Groups with each group having 4 options, Ineffective, Capable, Superior and N/A. Ineffective should have a checked value of 1, Capable should have a checked value of 2, Superior should have a checked value of 3 and N/A should have a checked value of -1. I want to write something in code to check the value of each groups option buttons and then present a total that will be divided by 10. I hope I've given you the info you need to help me out, but if not, please let me know and I'll try to explain further. Sometimes it is difficult to convey what you want in writing. I'm pretty much of a novice at this so can anyone help me out? I think that I need some kind of CASE statement, but not sure. Thanks very much in advance. |
#6
Posted to microsoft.public.word.tables
|
|||
|
|||
Setting a value to a option button & then calculating the total
You will need to unprotect the form, insert the value, reprotect the
form. Something like this incorporated at the end to the other macro should do: With ActiveDocument .Unprotect .FormFields("Total_Score").Result = pScore .Protect wdAllowOnlyFormFields, True End With wrote: Greg: Thank you for the quick response. If I wanted pScore to show up in a form field called "Total Score" how would I do that:? Greg Maxey wrote: Something like this should work: Sub Eval() Dim a, b, c, d, e, f, g, h, i, j As Long Dim pScore As Long With ThisDocument Select Case True 'First group Case .OptionButton1.Value a = 3 Case .OptionButton2.Value a = 2 Case .OptionButton3.Value a = 1 Case .OptionButton4.Value a = -1 Case Else MsgBox "No selection in Group 1" End Select Select Case True 'First group Case .OptionButton5.Value b = 3 Case .OptionButton6.Value b = 2 Case .OptionButton7.Value b = 1 Case .OptionButton8.Value b = -1 Case Else MsgBox "No selection in Group 2" End Select 'Repeat for groups 3 through 10 pScore = (a + b) / 2 'Test formula. Delete when you have create the other groups 'pScore = (a + b + c + d + e + f + g + h + i + j) / 10 'Real formula. MsgBox "Average score = " & pScore End With End Sub wrote: I am using MS Word 2003 to create a Word document form. I'm using tables to insert my form fields. In one table I have option buttons where the user must select one of the option buttons in that group. For example: My first Option button group would be named "Adaptability". Within the "Adaptability" Option button Group I have 4 option buttons: Ineffective, Capable, Superior and N/A. I have 10 Groups with each group having 4 options, Ineffective, Capable, Superior and N/A. Ineffective should have a checked value of 1, Capable should have a checked value of 2, Superior should have a checked value of 3 and N/A should have a checked value of -1. I want to write something in code to check the value of each groups option buttons and then present a total that will be divided by 10. I hope I've given you the info you need to help me out, but if not, please let me know and I'll try to explain further. Sometimes it is difficult to convey what you want in writing. I'm pretty much of a novice at this so can anyone help me out? I think that I need some kind of CASE statement, but not sure. Thanks very much in advance. |
#7
Posted to microsoft.public.word.tables
|
|||
|
|||
Setting a value to a option button & then calculating the total
Greg:
Thank you for the quick response. If I wanted pScore to show up in a form field called "Total Score" how would I do that:? Greg Maxey wrote: Yes sorry. Change the declaration of a, b, c, etc. and pScore to Double vice Long wrote: Greg: Also, I put your code in as shown below, but it doesn't seem to be calculating the total correctly. If "Ineffective" is = 1 and "Capable" is equal to 2 then the total would be 3 / 2 which would be 1.5 and I think it is rounding up. I don't want it to do that. Thanks, again! wrote: I am using MS Word 2003 to create a Word document form. I'm using tables to insert my form fields. In one table I have option buttons where the user must select one of the option buttons in that group. For example: My first Option button group would be named "Adaptability". Within the "Adaptability" Option button Group I have 4 option buttons: Ineffective, Capable, Superior and N/A. I have 10 Groups with each group having 4 options, Ineffective, Capable, Superior and N/A. Ineffective should have a checked value of 1, Capable should have a checked value of 2, Superior should have a checked value of 3 and N/A should have a checked value of -1. I want to write something in code to check the value of each groups option buttons and then present a total that will be divided by 10. I hope I've given you the info you need to help me out, but if not, please let me know and I'll try to explain further. Sometimes it is difficult to convey what you want in writing. I'm pretty much of a novice at this so can anyone help me out? I think that I need some kind of CASE statement, but not sure. Thanks very much in advance. |
#8
Posted to microsoft.public.word.tables
|
|||
|
|||
Setting a value to a option button & then calculating the total
Asked and answered. See earlier post in this string.
BTW, you can't have a formfield named "Total Score" as bookmark names cannot contain spaces. You could use "Total_Score" as in the example I provided. wrote: Greg: Thank you for the quick response. If I wanted pScore to show up in a form field called "Total Score" how would I do that:? Greg Maxey wrote: Yes sorry. Change the declaration of a, b, c, etc. and pScore to Double vice Long wrote: Greg: Also, I put your code in as shown below, but it doesn't seem to be calculating the total correctly. If "Ineffective" is = 1 and "Capable" is equal to 2 then the total would be 3 / 2 which would be 1.5 and I think it is rounding up. I don't want it to do that. Thanks, again! wrote: I am using MS Word 2003 to create a Word document form. I'm using tables to insert my form fields. In one table I have option buttons where the user must select one of the option buttons in that group. For example: My first Option button group would be named "Adaptability". Within the "Adaptability" Option button Group I have 4 option buttons: Ineffective, Capable, Superior and N/A. I have 10 Groups with each group having 4 options, Ineffective, Capable, Superior and N/A. Ineffective should have a checked value of 1, Capable should have a checked value of 2, Superior should have a checked value of 3 and N/A should have a checked value of -1. I want to write something in code to check the value of each groups option buttons and then present a total that will be divided by 10. I hope I've given you the info you need to help me out, but if not, please let me know and I'll try to explain further. Sometimes it is difficult to convey what you want in writing. I'm pretty much of a novice at this so can anyone help me out? I think that I need some kind of CASE statement, but not sure. Thanks very much in advance. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
paste option button | New Users | |||
option send to e-mail address (as attachment) unavailable | Microsoft Word Help | |||
Inserting an option button in Word | Microsoft Word Help | |||
how do I insert an option button within a table? | Tables | |||
multiple option button selections | Microsoft Word Help |