ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Forcing Date Entry (https://www.excelbanter.com/excel-programming/285562-forcing-date-entry.html)

rbaxter[_3_]

Forcing Date Entry
 
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


---
Message posted from http://www.ExcelForum.com/


Tom Ogilvy

Forcing Date Entry
 
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

"rbaxter" wrote in message
...
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


---
Message posted from http://www.ExcelForum.com/




KM[_2_]

Forcing Date Entry
 
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

"rbaxter" wrote in

message
...
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


---
Message posted from http://www.ExcelForum.com/



.


Tom Ogilvy

Forcing Date Entry
 
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" wrote in message
...
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

"rbaxter" wrote in

message
...
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


---
Message posted from http://www.ExcelForum.com/



.





All times are GMT +1. The time now is 11:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com