Date Entry

S

Sondra

Well I know this is possible, but I'll be darned if I can
figure it out.

I want to enter a date as 01012005 and have it show
01/01/2005 or 010105 as 01/01/05.

Please advise how this is done.

Everything I try doesn't work.

Thanks in advance
 
C

Chris2

Sondra said:
Well I know this is possible, but I'll be darned if I can
figure it out.

I want to enter a date as 01012005 and have it show
01/01/2005 or 010105 as 01/01/05.

Please advise how this is done.

Everything I try doesn't work.

Thanks in advance

Sondra,

Open Access. On the menus, go to Tools > Macro > Visual Basic Editor
(VBE).

Insert a new Module and paste in the following code.


Public Function TestDateEntry() As Date

Dim intMonth As String
Dim intDate As String
Dim intYear As String
Dim strEntry As String
Dim dtmCvnrtdDate As Date

' This may need to be inside a loop for data validation.
strEntry = InputBox("Enter Date", "Date Entry")

intMonth = CInt(Left(strEntry, 2))
intDate = CInt(Mid(strEntry, 2, 2))
intYear = CInt(Right(strEntry, 4))

dtmCvnrtdDate = DateSerial(intYear, intMonth, intDate)

TestDateEntry = dtmCvnrtdDate

End Function


On the menus in the VBE, View > Immediate.

Type in the Immediate Window: type "? TestDateEntry()", without the
quotes, and press enter.

The main Access Window will jump to the forefront, and an inputbox
will appear. Type in 01012005, just like that, and press enter.

01/01/2005 will appear in the Immediate Window (and what's more, it's
even a Date data-type).


Sincerely,

Chris O.
 

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