Forcing Date Entry

  • Thread starter Thread starter rbaxter
  • Start date Start date
R

rbaxter

Anyone know the code to use in order to force a user to fill in a
(text?)box with a date in the following format:

DD/MM/YY

If possible can the "/"s be already in place so that only the spaces
can be filled in eg. [ / / ]

Thanks
 
can't already have the /

no way to tell if the user complied or not

02/05/03

Did the user comply or not?

Use three textboxes - one for day, one for month, one for year
 
If you have text box you can use the IsDate function, I
use several functions to pull the locale date format of
the user but if you and your workbook are just based in
the US then just set a global string value of mm/dd/yy and
set your text box to this default value, itkind of acts as
a reminder to the user of what to type and on the _Exit
procdure of your text box you need to have something like
this

If Not IsDate(Me.txtBox) And Me.txtBox<> mstrDateFormat
Then
gstrFrmMsg = "The date that you have entered is not a
date value."
MsgBox gstrFrmMsg, vbOKOnly Or vbInformation
Me.txtBox= mstrDateFormat
Me.txtBox.SelStart = 0
Me.txtBox.SelLength = Len(Me.txtBox)
Cancel = True
End If

hope this helps
regards
KM
-----Original Message-----
can't already have the /

no way to tell if the user complied or not

02/05/03

Did the user comply or not?

Use three textboxes - one for day, one for month, one for year

--
Regards,
Tom Ogilvy

Anyone know the code to use in order to force a user to fill in a
(text?)box with a date in the following format:

DD/MM/YY

If possible can the "/"s be already in place so that only the spaces
can be filled in eg. [ / / ]

Thanks


.
 
This 02/05/03
would pass isdate whether it was

Feb 5 2003
May 2 2003
Mar 2 2005
etc.

If the OP were US why would they want the date as DD/MM/YY

Saying use
Me.txtBox<> mstrDateFormat

Without explaining what mstrDateFormat holds or how it is established is
pretty useless.

It might be useful to test for dd/mm/yy if the user will be using this yo
enter the date for some specific reason - beyond that, it is silly to
restrict entry to that format when other forms are non-ambiguous and can
easily be converted correctly to that format in code.

--
Regards,
Tom Ogilvy


KM said:
If you have text box you can use the IsDate function, I
use several functions to pull the locale date format of
the user but if you and your workbook are just based in
the US then just set a global string value of mm/dd/yy and
set your text box to this default value, itkind of acts as
a reminder to the user of what to type and on the _Exit
procdure of your text box you need to have something like
this

If Not IsDate(Me.txtBox) And Me.txtBox<> mstrDateFormat
Then
gstrFrmMsg = "The date that you have entered is not a
date value."
MsgBox gstrFrmMsg, vbOKOnly Or vbInformation
Me.txtBox= mstrDateFormat
Me.txtBox.SelStart = 0
Me.txtBox.SelLength = Len(Me.txtBox)
Cancel = True
End If

hope this helps
regards
KM
-----Original Message-----
can't already have the /

no way to tell if the user complied or not

02/05/03

Did the user comply or not?

Use three textboxes - one for day, one for month, one for year

--
Regards,
Tom Ogilvy

Anyone know the code to use in order to force a user to fill in a
(text?)box with a date in the following format:

DD/MM/YY

If possible can the "/"s be already in place so that only the spaces
can be filled in eg. [ / / ]

Thanks


.
 
Back
Top