Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Forms: Calculating Information based on Checkboxes
I have a form that I'm creating that needs to assign values to certain
checkboxes, then show those values in one spot, then add up a series of those values and display that, then show what percentage that creates. I am having a very hard time figuring this out. Can anyone help me? I am useless at understanding Macro coding so I really appreciate some step by step walking through it. I am good with forms, pretty clueless at Macros. Thanks in advance! |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Forms: Calculating Information based on Checkboxes
I posted this the other day for someone else with a similar, but slightly
different request. 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. You would have to give us a bit more information about your actual requirement to provide more specific information. -- 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 "pumpkin" wrote in message ... I have a form that I'm creating that needs to assign values to certain checkboxes, then show those values in one spot, then add up a series of those values and display that, then show what percentage that creates. I am having a very hard time figuring this out. Can anyone help me? I am useless at understanding Macro coding so I really appreciate some step by step walking through it. I am good with forms, pretty clueless at Macros. Thanks in advance! |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Forms: Calculating Information based on Checkboxes
Thank you - This has helped, although it is not quite working, and I think it
is my fault. I have already named all of my form fields because I knew this was going to be necessary, so I tried to fill in what I needed to your instructions, and somehow this is sort of messing up. Here is what I did: Private Sub TGLPIDPropY_Click() If TGLPIDPropY.Value = True Then ActiveDocument.FormFields TGLPIDPropScore.Result = 5 End If ActiveDocument.Fields.Update End Sub Private Sub TGLPIDNameY_Click() If TGLPIDNameY.Value = True Then ActiveDocument.FormFields TGLPIDNameScore.Result = 5 End If ActiveDocument.Fields.Update End Sub Private Sub TGLPAskNameY_Click() If TGLPAskNameY_Value = True Then ActiveDocument.FormFields TGLPAskNameScore.Result = 5 End If ActiveDocument.Fields.Update End Sub I also tried the following: Private Sub TGLPIDPropY_Click() If TGLPIDPropY.Value = True Then ActiveDocument.FormFields("TGLPIDPropScore").Resul t = 5 End If ActiveDocument.Fields.Update End Sub Private Sub TGLPIDNameY_Click() If TGLPIDNameY.Value = True Then ActiveDocument.FormFields("TGLPIDNameScore").Resul t = 5 End If ActiveDocument.Fields.Update End Sub Private Sub TGLPAskNameY_Click() If TGLPAskNameY.Value = True Then ActiveDocument.FormFields("TGLPAskNameScore").Resu lt = 5 End If ActiveDocument.Fields.Update End Sub I haven't gotten to the adding up the section part but that looks pretty simple. Thanks for your help...I really appreciate it. I have been banging my head against a brick wall all weekend with this. "Doug Robbins - Word MVP" wrote: I posted this the other day for someone else with a similar, but slightly different request. 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. You would have to give us a bit more information about your actual requirement to provide more specific information. -- 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 "pumpkin" wrote in message ... I have a form that I'm creating that needs to assign values to certain checkboxes, then show those values in one spot, then add up a series of those values and display that, then show what percentage that creates. I am having a very hard time figuring this out. Can anyone help me? I am useless at understanding Macro coding so I really appreciate some step by step walking through it. I am good with forms, pretty clueless at Macros. Thanks in advance! |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Forms: Calculating Information based on Checkboxes
The second attempt is the correct syntax, but is TGLPIDPropY an ActiveX
Radio Button or a Checkbox type Formfield? Give us more idea of the content of your form. -- 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 "pumpkin" wrote in message ... Thank you - This has helped, although it is not quite working, and I think it is my fault. I have already named all of my form fields because I knew this was going to be necessary, so I tried to fill in what I needed to your instructions, and somehow this is sort of messing up. Here is what I did: Private Sub TGLPIDPropY_Click() If TGLPIDPropY.Value = True Then ActiveDocument.FormFields TGLPIDPropScore.Result = 5 End If ActiveDocument.Fields.Update End Sub Private Sub TGLPIDNameY_Click() If TGLPIDNameY.Value = True Then ActiveDocument.FormFields TGLPIDNameScore.Result = 5 End If ActiveDocument.Fields.Update End Sub Private Sub TGLPAskNameY_Click() If TGLPAskNameY_Value = True Then ActiveDocument.FormFields TGLPAskNameScore.Result = 5 End If ActiveDocument.Fields.Update End Sub I also tried the following: Private Sub TGLPIDPropY_Click() If TGLPIDPropY.Value = True Then ActiveDocument.FormFields("TGLPIDPropScore").Resul t = 5 End If ActiveDocument.Fields.Update End Sub Private Sub TGLPIDNameY_Click() If TGLPIDNameY.Value = True Then ActiveDocument.FormFields("TGLPIDNameScore").Resul t = 5 End If ActiveDocument.Fields.Update End Sub Private Sub TGLPAskNameY_Click() If TGLPAskNameY.Value = True Then ActiveDocument.FormFields("TGLPAskNameScore").Resu lt = 5 End If ActiveDocument.Fields.Update End Sub I haven't gotten to the adding up the section part but that looks pretty simple. Thanks for your help...I really appreciate it. I have been banging my head against a brick wall all weekend with this. "Doug Robbins - Word MVP" wrote: I posted this the other day for someone else with a similar, but slightly different request. 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. You would have to give us a bit more information about your actual requirement to provide more specific information. -- 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 "pumpkin" wrote in message ... I have a form that I'm creating that needs to assign values to certain checkboxes, then show those values in one spot, then add up a series of those values and display that, then show what percentage that creates. I am having a very hard time figuring this out. Can anyone help me? I am useless at understanding Macro coding so I really appreciate some step by step walking through it. I am good with forms, pretty clueless at Macros. Thanks in advance! |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Forms: Calculating Information based on Checkboxes
My form is comprised of only form fields for writing text into, and check
boxes that you can make a little X into. That's what the TGLPIDPropY is - a checkbox with an X for "Yes". There are checkboxes for "No, which do not add up, and there are checkboxes for N/A" which I come to later on, which again do not factor in. I have to assign a value (usually 5 points) to the checkboxes and show it at the end of the line, and then add those points up in a box at the top of the screen, and then create percentages from those points that were received. The "totals" will need to be displayed in various points, both before and after the checkboxes that they were calculated from. If I need to change my checkboxes to ActiveX radio buttons, I think can do that, I just need some pointers on how to proceed. Does this answer? BTW - the second attempt didn't work, so I'm not sure what I'm doing wrong. Do I need to tell my checkboxes to run a macro or something? Thanks so much for your help! pumpkin "Doug Robbins - Word MVP" wrote: The second attempt is the correct syntax, but is TGLPIDPropY an ActiveX Radio Button or a Checkbox type Formfield? Give us more idea of the content of your form. -- 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 "pumpkin" wrote in message ... Thank you - This has helped, although it is not quite working, and I think it is my fault. I have already named all of my form fields because I knew this was going to be necessary, so I tried to fill in what I needed to your instructions, and somehow this is sort of messing up. Here is what I did: Private Sub TGLPIDPropY_Click() If TGLPIDPropY.Value = True Then ActiveDocument.FormFields TGLPIDPropScore.Result = 5 End If ActiveDocument.Fields.Update End Sub Private Sub TGLPIDNameY_Click() If TGLPIDNameY.Value = True Then ActiveDocument.FormFields TGLPIDNameScore.Result = 5 End If ActiveDocument.Fields.Update End Sub Private Sub TGLPAskNameY_Click() If TGLPAskNameY_Value = True Then ActiveDocument.FormFields TGLPAskNameScore.Result = 5 End If ActiveDocument.Fields.Update End Sub I also tried the following: Private Sub TGLPIDPropY_Click() If TGLPIDPropY.Value = True Then ActiveDocument.FormFields("TGLPIDPropScore").Resul t = 5 End If ActiveDocument.Fields.Update End Sub Private Sub TGLPIDNameY_Click() If TGLPIDNameY.Value = True Then ActiveDocument.FormFields("TGLPIDNameScore").Resul t = 5 End If ActiveDocument.Fields.Update End Sub Private Sub TGLPAskNameY_Click() If TGLPAskNameY.Value = True Then ActiveDocument.FormFields("TGLPAskNameScore").Resu lt = 5 End If ActiveDocument.Fields.Update End Sub I haven't gotten to the adding up the section part but that looks pretty simple. Thanks for your help...I really appreciate it. I have been banging my head against a brick wall all weekend with this. "Doug Robbins - Word MVP" wrote: I posted this the other day for someone else with a similar, but slightly different request. 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. You would have to give us a bit more information about your actual requirement to provide more specific information. -- 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 "pumpkin" wrote in message ... I have a form that I'm creating that needs to assign values to certain checkboxes, then show those values in one spot, then add up a series of those values and display that, then show what percentage that creates. I am having a very hard time figuring this out. Can anyone help me? I am useless at understanding Macro coding so I really appreciate some step by step walking through it. I am good with forms, pretty clueless at Macros. Thanks in advance! |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Forms: Calculating Information based on Checkboxes
There is no click event for a checkbox type formfield, which is what you
describe. What you need to do is run a macro such as the following on exit from an appropriate formfield (or all of the checkboxes in question. Sub SetValues() With ActiveDocument If .FormFields("TGLPIDPropY").CheckBox.Value = True Then .FormFields("TGLPIDPropScore").Result = 5 Else .FormFields("TGLPIDPropScore").Result = 0 End If If .FormFields("TGLPIDNameY").CheckBox.Value = True Then .FormFields("TGLPIDNameScore").Result = 5 Else .FormFields("TGLPIDNameScore").Result = 0 End If If .FormFields("TGLPAskNameY").CheckBox.Value = True Then .FormFields("TGLPAskNameScore").Result = 5 Else .FormFields("TGLPAskNameScore").Result = 0 End If End With End Sub -- 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 "pumpkin" wrote in message ... My form is comprised of only form fields for writing text into, and check boxes that you can make a little X into. That's what the TGLPIDPropY is - a checkbox with an X for "Yes". There are checkboxes for "No, which do not add up, and there are checkboxes for N/A" which I come to later on, which again do not factor in. I have to assign a value (usually 5 points) to the checkboxes and show it at the end of the line, and then add those points up in a box at the top of the screen, and then create percentages from those points that were received. The "totals" will need to be displayed in various points, both before and after the checkboxes that they were calculated from. If I need to change my checkboxes to ActiveX radio buttons, I think can do that, I just need some pointers on how to proceed. Does this answer? BTW - the second attempt didn't work, so I'm not sure what I'm doing wrong. Do I need to tell my checkboxes to run a macro or something? Thanks so much for your help! pumpkin "Doug Robbins - Word MVP" wrote: The second attempt is the correct syntax, but is TGLPIDPropY an ActiveX Radio Button or a Checkbox type Formfield? Give us more idea of the content of your form. -- 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 "pumpkin" wrote in message ... Thank you - This has helped, although it is not quite working, and I think it is my fault. I have already named all of my form fields because I knew this was going to be necessary, so I tried to fill in what I needed to your instructions, and somehow this is sort of messing up. Here is what I did: Private Sub TGLPIDPropY_Click() If TGLPIDPropY.Value = True Then ActiveDocument.FormFields TGLPIDPropScore.Result = 5 End If ActiveDocument.Fields.Update End Sub Private Sub TGLPIDNameY_Click() If TGLPIDNameY.Value = True Then ActiveDocument.FormFields TGLPIDNameScore.Result = 5 End If ActiveDocument.Fields.Update End Sub Private Sub TGLPAskNameY_Click() If TGLPAskNameY_Value = True Then ActiveDocument.FormFields TGLPAskNameScore.Result = 5 End If ActiveDocument.Fields.Update End Sub I also tried the following: Private Sub TGLPIDPropY_Click() If TGLPIDPropY.Value = True Then ActiveDocument.FormFields("TGLPIDPropScore").Resul t = 5 End If ActiveDocument.Fields.Update End Sub Private Sub TGLPIDNameY_Click() If TGLPIDNameY.Value = True Then ActiveDocument.FormFields("TGLPIDNameScore").Resul t = 5 End If ActiveDocument.Fields.Update End Sub Private Sub TGLPAskNameY_Click() If TGLPAskNameY.Value = True Then ActiveDocument.FormFields("TGLPAskNameScore").Resu lt = 5 End If ActiveDocument.Fields.Update End Sub I haven't gotten to the adding up the section part but that looks pretty simple. Thanks for your help...I really appreciate it. I have been banging my head against a brick wall all weekend with this. "Doug Robbins - Word MVP" wrote: I posted this the other day for someone else with a similar, but slightly different request. 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. You would have to give us a bit more information about your actual requirement to provide more specific information. -- 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 "pumpkin" wrote in message ... I have a form that I'm creating that needs to assign values to certain checkboxes, then show those values in one spot, then add up a series of those values and display that, then show what percentage that creates. I am having a very hard time figuring this out. Can anyone help me? I am useless at understanding Macro coding so I really appreciate some step by step walking through it. I am good with forms, pretty clueless at Macros. Thanks in advance! |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
E-mail forms and Checkboxes | Microsoft Word Help | |||
Calculating based on text expressions in formfields - Word 2003 | Microsoft Word Help | |||
Refencing other checkboxes in forms. | Microsoft Word Help | |||
calculating, branching in Word forms | Microsoft Word Help | |||
Disappearing Checkboxes in Forms | Microsoft Word Help |