Form Date Field- Does user have to type separators?

M

Mary

I do not want the user to have to type slashes or hyphens for a date. So,
for a format of 02/05/09, is there a way to make it so that the user just
types 020509 and hits tab and upon exit, the correct formatting is applied?

We are using Word 2000.

Thanks,
 
G

Graham Mayor

If you want to force a particular date format it is much simpler to use a
pop-up calendar on entry to the field, to allow the user to select the date,
and then format the result as you require it - see
http://www.gmayor.com/popup_calendar.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

Mary

Thanks Graham. Not sure it will give me what I want but going to your
Website has given me access to some good reference information.

I use an Access database at work that has a pre-formatted date field where I
just type the numbers and it automatically formats it with the correct
slashes where appropriate. I assumed (and we know what that means) that it
could also be done in Word.

I have much to learn.
 
G

Graham Mayor

You certainly can pre-format a date form field, but it will not allow you to
simply type 020809 and produce a valid date. It will only reformat a valid
date eg 02/08/09. To reformat any combination of digits to produce a date
can be done by macro, provided you know all the likely formats that users
may enter. It is much simpler to let the user pick a date from a calendar
and then insert the picked date in any format you prefer. To make the
calendar insert the date into your form field (here Text2) in the format
02-08-09, change the line

oFld("Text2").Result = Format(Calendar1.Value, "dd mmmm yyyy")
to
oFld("Text2").Result = Format(Calendar1.Value, "MM-dd-yy")

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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