Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Jan 2008
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using 'DateAdd' (2003)

    I need to take a text field date and make a reference field which shows the date 10 years back.

    After going through DateCalc V2_75.doc a few times, I cannot resolve how to reference a date formatted text field as a date to be subtracted from. (Shift-F9 in the text field reveals "{ FORMTEXT }" as any other text field, although I don't know if this affects how to manipulate the contents of the field)

    Can A REF field be written with DateAdd to add -10 years to contents of a text field?

    Here is my best bungling:

    {REF DateAdd("yyyy", -10, DateTextFieldName)h *MERGEFORMAT}

    Using "DateTextFieldName" in place of "Date", which I assume is the current date on the system, seems problematic.

    Also, I have no Bookmark immediately following "REF" which must be wrong.

    Any help?

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

    Re: Using 'DateAdd' (2003)

    DateAdd is a Visual Basic function, you can't use it in a Word document, and it isn't used in Macropod's Date Calculations document, so I don't know how you got the idea to use it.

    A form text field has a bookmark name that you can view and set while the document is unprotected - double click the form field to see its properties. You can use the bookmark name in a REF field to refer to the form field elsewhere in the document. You should tick the check box Calculate on Exit to ensure that the REF field will be updated automatically.

    The screenshot below shows what the field should look like if you name your text form field MyDate.
    It's for DMY date format, as in Macropod's document. For MDY format, switch {mm} and {dd} near the end.
    Attached Images Attached Images
    • File Type: png x.png (6.3 KB, 0 views)

  3. #3
    Star Lounger
    Join Date
    Jan 2008
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using 'DateAdd' (2003)

    After trying to use the code example Hans provided, I keep getting the "too many switches" error code.

    I changed the name of the bookmark, and I changed the date format at the end.

    After a couple hours here and there of playing with it, I still can't see the problem.

    I'm uploading a Word Document, which has the reference field code that isn't working...
    Attached Files Attached Files

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

    Re: Using 'DateAdd' (2003)

    You should *never* type the field braces { } yourself. Either press Ctrl+F9 to insert them, or use Insert | Field... to insert a complete field.
    In your sample document, the only real field braces are the outer ones, for the QUOTE field. All others have been typed manually, which means that they are invalid.

    As an example, if you want to insert a REF field that refers to EffectiveThroughDate, you can do it in any of the following ways:

    - Press Ctrl+F9, then type <code>REF EffectiveThroughDate</code>

    or

    - Type <code>REF EffectiveThroughDate</code> then select this text and press Ctrl+F9

    or

    - Select Insert | Field..., select Ref in the list of field names, select EffectiveThroughDate in the list of bookmarks, then click OK.

  5. #5
    Star Lounger
    Join Date
    Jan 2008
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using 'DateAdd' (2003)

    Aha! The real field braces look fuzzy when inserted correctly. Thanks a ton. I would have taken weeks to figure that out!

Posting Permissions

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