Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Jul 2015
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DOB/age calculation in Word 2010

    Hello there,

    I have been been trying to work with form fields in Word 2010 tables to calculate a person's age in a box/cell titled "Age" using the date of birth that I enter into another box/cell called "DOB". I've been trying to follow your posts across the web, and even read your tutorial, but I still cannot seem to get the field code I put into the "Age" box to recognize the date I entered into the "DOB" box and do the math to produce the age in years. This is despite my bookmarking the date in the "DOB" box as "BirthDate".

    I even used the exact field code from your discussion here: https://social.msdn.microsoft.com/Fo...lation-in-word

    When I update the field in the "Age" box with the above code I get a blank output (no content visible in the box/cell). I simply don't understand what I am doing wrong.

    Can you please help me by telling me what I might be doing wrong? Maybe I'm just not configuring the "DOB" box properly? Might you have a template that does this function to share?

    Thanks!

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Without actually seeing the problem document, it can be difficult for anyone to diagnose the issue. Can you attach a document to a post with some representative data (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.

    PS: Please don't address threads to individual members.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    New Lounger
    Join Date
    Jul 2015
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have attached the requested file using dummy information (nothing sensitive). It's a simple table with three boxes; the third "Age" box contains the field code you posted on the MSDN forum. I was just thinking, I noted your instructions say that the "BirthDate" bookmark should be attached to a form field containing the DOB. But I could not actually create a form field and figure out how to fill it with a DOB in that second box. So maybe there's the problem.

    That second box that contains the DOB is currently just filled in with text. That was the only way I could bookmark the DOB with "BirthDate". Ideally, I'd like it to be like the first box (name), which is to say to be able to fill in the DOB as a plain text content control (w/ date picker format/properties). But doing that made it impossible for me to highlight it and bookmark it. And I don't get how to enter a DOB in that box if I replaced the plain text content control with a form field. Inserting a form field creates a gray-shaded portion of the box that I cannot enter any text into.

    As you can see, I'm stil pretty new to these developer tools and especially form fields and field codes. And while I'm certainly no programmer, I have enough courage to think I can get this to work!

    I appreciate any help you can provide.

    Thanks again!
    Attached Files Attached Files

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    When I examine your document, there is no 'BirthDate' bookmark. Furthermore, you've not paid sufficient attention to the Note in the link:
    The field brace pairs (ie '{ }') for the above example are created via Ctrl-F9 - you can't simply type them or copy & paste them from this message.
    Other than the outer pair of field braces for your formula field, all the braces in your implementation are ordinary ones. Furthermore, had you downloaded a copy of my Microsoft Word Date Calculation Tutorial from either of the links in the MSDN thread, you would have been able to find there a fully-working copy of the field - it's based on the item titled 'Interactively Calculate A Person’s Age' in the tutorial (you'll find it as a 'Sticky' thread at the top of this forum).
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    New Lounger
    Join Date
    Jul 2015
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, I see about the brace pairs...you were referring to all of them across the entire code, not just the opening and closing ones. I was also able to substantively address all the other unanswered issues as well I first wrote about, so I'm satisfied. I appreciate you looking at the code and your suggestion, but I thought your language in the last reply a little harsh on someone who did not even know what field codes were before last Saturday. Even your tutorial, helpful as it is, is no easy ground for a novice (and I did read it, FWIW).

    Having said that, I reiterate my gratitude.

Posting Permissions

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