A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Setting a value to a option button & then calculating the total



 
 
Thread Tools Display Modes
  #1  
Old June 16th, 2006, 03:45 PM posted to microsoft.public.word.tables
external usenet poster
 
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  
Old June 16th, 2006, 04:27 PM posted to microsoft.public.word.tables
external usenet poster
 
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  
Old June 16th, 2006, 05:36 PM posted to microsoft.public.word.tables
external usenet poster
 
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  
Old June 16th, 2006, 05:40 PM posted to microsoft.public.word.tables
external usenet poster
 
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  
Old June 16th, 2006, 06:19 PM posted to microsoft.public.word.tables
external usenet poster
 
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  
Old June 16th, 2006, 06:26 PM posted to microsoft.public.word.tables
external usenet poster
 
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  
Old June 16th, 2006, 06:40 PM posted to microsoft.public.word.tables
external usenet poster
 
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  
Old June 16th, 2006, 06:52 PM posted to microsoft.public.word.tables
external usenet poster
 
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.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating Business Hours Between 2 Dates tanya216 General Discussion 2 April 11th, 2006 03:22 PM
Alarm problem Kay Using Forms 1 March 28th, 2006 04:30 PM
Pivot table for reporting sales performance Ram General Discussion 2 February 6th, 2006 10:06 AM
Option group button navigation ctdak Using Forms 8 November 11th, 2005 06:42 PM
Calculating Total Number of Minutes in a Clock Setting Larry H General Discussion 3 October 7th, 2005 11:25 PM


All times are GMT +1. The time now is 08:28 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.