How do I autofill the slashes(2008/04/12)in the date fields on a f

L

Lori

It would be more convenient for the users of the form not to have to type the
slashes in the date (ie: 2008/04/12) How do I put the slashes in the date
fields on click?
 
J

Jim Aksel

If you are talking about a regular Project form, such as shown on the Gantt
Chart for "Start" or similar, an error is generated unless the date is
entered in a recognized format. Sorry, 20080412 is not a standard format, it
needs a delimeter. For example 2008/04/12 and 2008/4/12.... See how it
would get confused?

If you are talking about a custom form you are developing, you need to make
some assumptions about the order the information was entered, and the length
of the field entered. Then you can chop up the user entry accordingly.
--
If this post was helpful, please consider rating it.

Jim

Visit http://project.mvps.org/ for FAQs and more information
about Microsoft Project
 
R

Rod Gill

Hi,

Try:

Sub Test()
Dim Reply As String
Dim D As Date
Reply = "20080412"
If Len(Reply) <> 8 Then
MsgBox "Please enter valid 8 character date string", vbCritical +
vbOKOnly
Else
D = DateSerial(CInt(Left(Reply, 4)), CInt(Mid(Reply, 5, 2)),
CInt(Right(Reply, 2)))
MsgBox "Date is: " & Format(Date, "Long Date")
End If
End Sub


--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.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