Auto entering year in date field

G

Guest

My boss wanted a particular date field to already have the current year
entered and only make the user enter the month and day, then enable and enter
key to move to the next field. In the Got Focus event for the text box where
the date is entered I have: MeTrackingNoteVendDate.InputMask = "99/99/\" &
Right$(Year(Now()), 2) & ";0;_" -- This worked well up to now and then its
behavior made me smack myself in the forehead with my palm. I should have
seen that this would make the year noneditable, which is not acceptable at
this time of year when some dates (this is an expected date) might be for
next year. Does anyone know how I could get it to enter the year as a
default but not have it be overwritten when someone puts a date in the field,
while allowing the user to change the year? In other words, the field looks
like __/__/05 but you can also change the 05 (or 06 starting next year) to
any necessary year. Thank you in advance for your time and your responses.
 
F

fredg

My boss wanted a particular date field to already have the current year
entered and only make the user enter the month and day, then enable and enter
key to move to the next field. In the Got Focus event for the text box where
the date is entered I have: MeTrackingNoteVendDate.InputMask = "99/99/\" &
Right$(Year(Now()), 2) & ";0;_" -- This worked well up to now and then its
behavior made me smack myself in the forehead with my palm. I should have
seen that this would make the year noneditable, which is not acceptable at
this time of year when some dates (this is an expected date) might be for
next year. Does anyone know how I could get it to enter the year as a
default but not have it be overwritten when someone puts a date in the field,
while allowing the user to change the year? In other words, the field looks
like __/__/05 but you can also change the 05 (or 06 starting next year) to
any necessary year. Thank you in advance for your time and your responses.

Get rid of the input mask.
Simply entering 12/2 in the date field will then automatically be
saved as 12/2/2005 (or whatever the current year is).
You can always enter a full date to store a different year.

Don't confuse the formatted display of a date with it's stored value.
A date's value is a Double number (today is 38688) regardless of
whether it's displayed as 12/2/05 or 12/2/2005.


You can format the control to show the date however you wish, i.e.
12/2/05.
 

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

Top