Results 1 to 3 of 3
  1. #1
    Uranium Lounger
    Join Date
    Dec 2000
    Los Angeles Area, California, USA
    Thanked 0 Times in 0 Posts

    Form Field Date Formats (Word 2000/SR-1)

    Hi WOPRs:
    A user has posed a question involving the date format in a form field & I think it's a bug. I can't even find a mention of it on the Microsoft Knowledge Base.

    Suppose you insert a form field in a document that has other form fields, change the property to be a date format, & format it to appear as MM/yy. If you now protect the document, here's what happens:

    <table border=1><td align=center valign=top>Type</td><td align=center valign=top>Result when you tab out</td><td align=center valign=top>Result when you retab in</td><td valign=top>08-03</td><td valign=top>08-02</td><td valign=top>08-02</td><td valign=top>08-6-03</td><td valign=top>08-03</td><td valign=top>08-02</td><td valign=top>08-2003</td><td valign=top>08-03</td><td valign=top>08-02</td></table>
    Note that if you were to have the format as MM/d/yy, the year wouldn't change. But if you only have month & year, no matter what you type, you will eventually get the current year.

    Microsoft seems to be unaware of this. In a KB article at;q209727&

    they imply that typing a 2 digit date into a form field will remain as typed, but that if the date is before January 1, 1930 or after December 31, 2029, you must use the 4 digit year. That might be true, but the 2 digit field isn't correct.

    Does anyone know a solution to this?
    Does anyone get a different result?

    Thanks in advance.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Silicon Valley, USA
    Thanked 94 Times in 90 Posts

    Re: Form Field Date Formats (Word 2000/SR-1)

    I get the same thing with SP2 applied. I'm guessing that Word "assumes" you have typed the month and day and that Word should add the current year to it. Bad assumption!

    This is absurd, but it seems to work:

    <pre>Sub UpdateDate()
    Dim strDate As String
    strDate = ActiveDocument.FormFields("Text2").Result
    strDate = InputBox("Enter date in MM-YY format", "Workaround", strDate)
    If strDate = vbNullString Then
    ActiveDocument.FormFields("Text2").Result = vbNullString
    Exit Do
    ElseIf Len(strDate) = 5 Then
    'Move to the next FormField before updating or it will be for naught
    ActiveDocument.FormFields("Text2").Result = _
    Left(strDate, 2) & "-15-" & Right(strDate, 2)
    End If
    Loop Until Len(strDate) = 5
    End Sub</pre>

    Other than that, I don't see any workaround that wouldn't be hard on the user.

  3. #3
    5 Star Lounger
    Join Date
    Jul 2002
    Toronto, Ontario, Canada
    Thanked 0 Times in 0 Posts

    Re: Form Field Date Formats (Word 2000/SR-1)

    There is a much easier work around, change the field format to a number and the format to 00/00

    Sure there is no way ensure it's a valid date, but much easier than using a macro.
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

Posting Permissions

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