Results 1 to 10 of 10
  1. #1
    Star Lounger
    Join Date
    Jun 2001
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Check Box and Calculated Field (2002/SP-2)

    Apologies since I am sure this answer is already out there - but I am having no luck in my search...

    Problem: How to get an inserted field to calculate based on the results of a checkbox.

    I used the forms toolbar to insert a checkbox into a table, and would like another field (called "Points") to return the number 2 if the box is checked and a number 0 if it is not. Was hoping there was a way to do this without a macro by (1) defining the "Points" field via formula (ala "IF Check1 = CHECKED 2 0"), and (2) setting the Check Box Form Field Options to "Calculate on exit".

    But what I am doing is not working - not sure if I have a syntax problem or something more fundamental. See attachment.

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Check Box and Calculated Field (2002/SP-2)

    I don't know how to mix the ActiveX checkbox with a word IF field. Can you use the regular Forms toolbar checkbox instead? That might work better, although I haven't tested that either. (Big help I am...)

  3. #3
    Star Lounger
    Join Date
    Jun 2001
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Check Box and Calculated Field (2002/SP-2)

    I am a bit fuzzy on the terminology, but I think I AM using the "regular Forms toolbar checklist" you mention. When I look at Properties it shows a "Check Box Form Field Options" dialog that shows it with a Bookmark of "Check1" - if that clarifies.

    - AND have tried directly entering the IF statement in the Edit Fields dialog "Field codes:" input line (where it displays under the input line "IF Expression1 Operator Expression2 TrueText FalseText").
    - AND have also tried entering IF as a formula by selecting "=(Formula)" from the Edit Fields dialog "Field names:" section and then clicking the "Formula..." button.

    Seems like this SHOULD be working. It is returning a value (and not an error) - just not the correct value.

    Bill
    <img src=/S/confused3.gif border=0 alt=confused3 width=45 height=45>

  4. #4
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Check Box and Calculated Field (2002/SP-2)

    I took a look at your attachment. It uses the forms toolbar to insert a checkbox formfield & is bookmarked. However, it doesn't have a value, that I could determine. I put in a ref field, {REF Check1}, & it didn't show anything, regardless of whether the box was checked or not. In that case, I don't know how you would use an IF field.

    I think you would need a macro, that would run on exit, to insert 0 or 2, depending on the state of the checkbox. I'm not sure how to do that, though.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Check Box and Calculated Field (2002/SP-2)

    Perhaps someone else knows how to do this without a macro, I don't. I have attached a zipped modified version of the document, with a macro that is called when you exit the check box. The macro is very simple:

    Sub Exit_Check1()
    ActiveDocument.FormFields("Text1").Result = _
    -2 * ActiveDocument.FormFields("Check1").CheckBox.Value
    End Sub

    The Value of the check box is 0 if clear, -1 if ticked.
    Attached Files Attached Files

  6. #6
    Star Lounger
    Join Date
    Jun 2001
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Check Box and Calculated Field (2002/SP-2)

    Hans -

    This is great - and simple enough that I even understand it.

    Concerns I have are
    1. There are 84 contractual terms (the sample contained 1) that must be evaluated (scored) - which means 84 macros - which is sort of a maintenance issue
    2. I have a =SUM(ABOVE) field at the bottom of the table - which does not seem to be recognizing the value the macro produces as a value

    Any thoughts on how to handle #2 especially?

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Check Box and Calculated Field (2002/SP-2)

    Sorry, I lost my mind for a few minutes there. <img src=/S/sad.gif border=0 alt=sad width=15 height=15>

  8. #8
    Star Lounger
    Join Date
    Jun 2001
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Check Box and Calculated Field (2002/SP-2)

    Nevermind - did not realize =SUM(ABOVE) "stopped" summing once a blank line is reached - have changed the formula to "=SUM(b2:b85)" and seems to be working. Have already created >30 of the "Sub Exit_CheckN" macros - not as big a deal as I feared. Even figured out how to alter the macro to work on groups of mutually exclusive choices - cool.

    Thanks for your help everyone!

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Check Box and Calculated Field (2002/SP-2)

    > 1. There are 84 contractual terms (the sample contained 1) that must be evaluated (scored) -
    > which means 84 macros - which is sort of a maintenance issue

    Or one macro that checks 84 different fields. <img src=/S/grin.gif border=0 alt=grin width=15 height=15> Your choice.

  10. #10
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Check Box and Calculated Field (2002/SP-2)

    For a good solution to the sum(above) problem, see http://word.mvps.org/faqs/TblsFldsFms/TotalColumn.htm.
    Cheers,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •