date mask via vba?

D

DavidP

Anyone have any code to simulate a date mask on a Word form that works like a
date mask on an Access form. i.e. slashes are automatically entered as user
types a date in the format mm/dd/yyyy
 
G

Graham Mayor

If this is a protected form field, set its property type to Date and apply a
mask. Protect the form, then any valid date input will be converted to match
your mask. No vba required.

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
D

DavidP

I don't know what you mean. Are you talking about form fields in a document?

I'm talking about forms in the VBA editor. Maybe I should have said a field
 
G

Gordon Bentley-Mix

You could use the Change event for the TextBox control to do this, but it
might be a bit tricky to implement and not really worth the effort. I'd
probably go with formatting (and validation) on the Exit event. First use
the IsDate function to make sure the .Value is a date, and then use the
Format function and "mm/dd/yyyy" to format the value. I can post some code
if you need it, but you should be able to find enough information in the VBA
help to get you started. Look for the topics on the Exit event, the IsDate
function and the Format function.
 

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