Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
 
Posts: n/a
Default 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.

  #2   Report Post  
Posted to microsoft.public.word.tables
Greg Maxey
 
Posts: n/a
Default Setting a value to a option button & then calculating the total

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.


  #3   Report Post  
Posted to microsoft.public.word.tables
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.word.tables
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.word.tables
Greg Maxey
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.word.tables
Greg Maxey
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.word.tables
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.word.tables
Greg Maxey
 
Posts: n/a
Default 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

Posting Rules

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
paste option button [email protected] New Users 1 June 15th 05 02:58 AM
option send to e-mail address (as attachment) unavailable NotAnExpert Microsoft Word Help 1 April 20th 05 03:36 PM
Inserting an option button in Word Query on inserting an option button Microsoft Word Help 2 April 12th 05 08:59 AM
how do I insert an option button within a table? shutter_bugz Tables 0 February 24th 05 04:59 PM
multiple option button selections questions Microsoft Word Help 1 February 15th 05 05:57 PM


All times are GMT +1. The time now is 03:42 AM.

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"