Previous Year in a Date Field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using Word 2002.

I have a date field, the date format is MMMM yyyy. If I enter 10/04 the
field shows October 2005, it doesn't accept any previous year. I need the
user to be able to enter information from any month of a previous year to any
current month year. How can I get the field to accept the previous year(s)?

Thanks for your help.
 
Jamie said:
I'm using Word 2002.

I have a date field, the date format is MMMM yyyy. If I enter 10/04
the field shows October 2005, it doesn't accept any previous year. I
need the user to be able to enter information from any month of a
previous year to any current month year. How can I get the field to
accept the previous year(s)?

Thanks for your help.

Word is guessing about how to interpret what you typed, and it's guessing
wrong. You'll have to supply the "smarts" yourself...

When you enter 10/04 in the field, Word assumes that these are the month and
the *day* (or vice versa, depending on your Regional date settings in
Windows), and goes on from there to assume that you omitted the year so you
must have meant this year. Hence the result October 2005.

If the second part of the date clearly can't be a day number -- for example,
10/95 -- then the field guesses that it must be the last two digits of a
year beginning with '19'. It isn't programmed to assume a year beginning
with '20' at all.

You can either enter all three parts of the date (choosing any day, as that
will be discarded) as 10/1/04 or you can enter the year as all four digits,
10/2004. Either of those entries will display a result of October 2004. I
can't think of any way to force the field to recognize your entry the way
you intended in all circumstances.
 
Hi Jay, thanks for your response. Can I use an on entry macro to show the
date that is entered by the user? If so, how would I go about doing this.
 
Hi Jamie,

Do you mean this: after the user enters something like 10/2004 and tabs out
of the field, and the field reformats it to October 2004, then the user
reenters the field, and you want to somehow show the original typed value
10/2004?

If that's what you want, the answer is "sorry, no, not with this kind of
field". The field has no memory of what was typed; all it retains is the
final formatted display.

If you really need something like this, it will be much more complicated.
Set the field's Type property to "regular text" instead of "Date". Create an
exit macro that first stores the user's typed entry in a document variable
and then validates and reformats the entry (reinventing the wheel to
duplicate the Date field's automatic processing). Then you can write a
separate entry macro that retrieves the value of the document variable and
displays it (in the original form field, a message box, a userform, or the
status bar -- designer's choice).

Also be aware that including macros means that the document will trigger the
macro security warning whenever it's opened.
 
Ok, thanks for your help Jay.

Jay Freedman said:
Hi Jamie,

Do you mean this: after the user enters something like 10/2004 and tabs out
of the field, and the field reformats it to October 2004, then the user
reenters the field, and you want to somehow show the original typed value
10/2004?

If that's what you want, the answer is "sorry, no, not with this kind of
field". The field has no memory of what was typed; all it retains is the
final formatted display.

If you really need something like this, it will be much more complicated.
Set the field's Type property to "regular text" instead of "Date". Create an
exit macro that first stores the user's typed entry in a document variable
and then validates and reformats the entry (reinventing the wheel to
duplicate the Date field's automatic processing). Then you can write a
separate entry macro that retrieves the value of the document variable and
displays it (in the original form field, a message box, a userform, or the
status bar -- designer's choice).

Also be aware that including macros means that the document will trigger the
macro security warning whenever it's opened.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top