Automatically completing incomplete date data entry

K

keliie

I've done some searching in the groups and can't find an answer to this
question, so here goes.

Context:
My application has a lot of date data entry throughout. All dates are
entered in "Short Date" format. Users (primarily myself) want to be
able to enter an incomplete date (e.g., "9/20", "9/06") and have the
application complete the remainder of the date (e.g., "9/20/2006",
"9/1/2006"). As the developer, I want to be able to accomplish this
task by using a Public Sub or Function that can be accessed by any
form.

Question:
Can anyone share their ideas on where to start, or even perhaps some
code samples that can get me started on the task of automatically
completing partially completed dates, as shown in the examples above?

Thanks for any help,

Kelii
 
J

JK

Kelii,

Just do it.
Set your field to date/Time field, any format you wish and the input musk to
"00/00;0;_" (no quotation marks unless you do it in VB)

Access will add the current year - you might though have a problem if you
entering December dates in the following January


Regards.JK
 
J

John Vinson

My application has a lot of date data entry throughout. All dates are
entered in "Short Date" format. Users (primarily myself) want to be
able to enter an incomplete date (e.g., "9/20", "9/06") and have the
application complete the remainder of the date (e.g., "9/20/2006",
"9/1/2006"). As the developer, I want to be able to accomplish this
task by using a Public Sub or Function that can be accessed by any
form.

Ummm... the first of these is builtin functionality and requires no
code at all. If you remove any Input Masks from a date/time field,
Access will fill in the current year.

HOWEVER - your second example is NOT reasonable. Joe might intend 9/06
to mean September 6, 2006; Janet might intend the exact same
keystrokes, 9/06, to mean September 1, 2006. The computer is not
telepathic and cannot determine which you mean! Even if you argue that
9/6 means September 6, and 9/06 means "sometime in September 2006",
what will you do in four years with 9/10?

John W. Vinson[MVP]
 

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