ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Validating a long date in VBA (https://www.excelbanter.com/excel-programming/319311-validating-long-date-vba.html)

will

Validating a long date in VBA
 
Hi Everyone, new VBA coder here.

I just wondered if there was an easy of tackling this problem please:

I have a text box on a form which defaults to the current date in long
form i.e. ddd-dd-mm-yyyy. (Obviously this would be mm-dd in some
countries, but this doesn't matter here.)

9 times out of 10 the user won't need to change this date but they may
have to. They will be able to change the current date, for instance,
to yesterday's date rather than today's. Trouble is, they may enter a
valid date but the day of the week wouldn't change automatically,
leading to invalid data - unless they changed it manually.

Is there some way that I can validate a long date? I have come across
some date-validation routines but they only check whether a date is
valid rather than a date-day combination.

Thank you for any insight into this.

W

Frank Kabel

Validating a long date in VBA
 
Hi
I'd choose a different approach. Use this format only for display and have
for example three texboxes (and/or listboxes/spinner controls) to enter the
values for day, month, year separately (and check them). After eentering
update your displayed date

--
Regards
Frank Kabel
Frankfurt, Germany
"will" schrieb im Newsbeitrag
om...
Hi Everyone, new VBA coder here.

I just wondered if there was an easy of tackling this problem please:

I have a text box on a form which defaults to the current date in long
form i.e. ddd-dd-mm-yyyy. (Obviously this would be mm-dd in some
countries, but this doesn't matter here.)

9 times out of 10 the user won't need to change this date but they may
have to. They will be able to change the current date, for instance,
to yesterday's date rather than today's. Trouble is, they may enter a
valid date but the day of the week wouldn't change automatically,
leading to invalid data - unless they changed it manually.

Is there some way that I can validate a long date? I have come across
some date-validation routines but they only check whether a date is
valid rather than a date-day combination.

Thank you for any insight into this.

W





All times are GMT +1. The time now is 12:38 PM.

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