Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Getting user's Date from a Form
How do I get a date from a user, via a form, and then validate their entry,
please? I currently have textboxes and labels as follows: ........... / ........... / ................ tbDay Lb tbMonth Lb tbYear where "16/05/2005" would be validated, but "30/02/2005" (for example) should not be validated........ don't remember 30 days in February anytime recently. Surely there is an easier way than having to write all the validating code? Regards. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Getting user's Date from a Form
Hi
You can test the day number is the same in the textbox and in the date you create with the three textboxes Use If Day(DateSerial(Me.text1, Me.text2, Me.text3)) =daytextbox then -- Regards Ron de Bruin http://www.rondebruin.nl "Stuart" wrote in message ... How do I get a date from a user, via a form, and then validate their entry, please? I currently have textboxes and labels as follows: .......... / ........... / ................ tbDay Lb tbMonth Lb tbYear where "16/05/2005" would be validated, but "30/02/2005" (for example) should not be validated........ don't remember 30 days in February anytime recently. Surely there is an easier way than having to write all the validating code? Regards. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Getting user's Date from a Form
Many thanks, but I may not have explained correctly.
I wish to let the user specify a date (any date of their choice) but then check it's validity against (eg): it cannot be 30th February it cannot be 32nd December it cannot be 0th any Month etc Hope this is clearer. Regards. "Ron de Bruin" wrote in message ... Hi You can test the day number is the same in the textbox and in the date you create with the three textboxes Use If Day(DateSerial(Me.text1, Me.text2, Me.text3)) =daytextbox then -- Regards Ron de Bruin http://www.rondebruin.nl "Stuart" wrote in message ... How do I get a date from a user, via a form, and then validate their entry, please? I currently have textboxes and labels as follows: .......... / ........... / ................ tbDay Lb tbMonth Lb tbYear where "16/05/2005" would be validated, but "30/02/2005" (for example) should not be validated........ don't remember 30 days in February anytime recently. Surely there is an easier way than having to write all the validating code? Regards. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Getting user's Date from a Form
It is doing that Stuart
Day(DateSerial(Me.text1, Me.text2, Me.text3)) For example if you fill in 2005,2,30 in the textboxes MsgBox Day(DateSerial(2005, 2, 30)) will give you day number 2 So if you test if the day number in the textbox is the same then you know you have a valid date -- Regards Ron de Bruin http://www.rondebruin.nl "Stuart" wrote in message ... Many thanks, but I may not have explained correctly. I wish to let the user specify a date (any date of their choice) but then check it's validity against (eg): it cannot be 30th February it cannot be 32nd December it cannot be 0th any Month etc Hope this is clearer. Regards. "Ron de Bruin" wrote in message ... Hi You can test the day number is the same in the textbox and in the date you create with the three textboxes Use If Day(DateSerial(Me.text1, Me.text2, Me.text3)) =daytextbox then -- Regards Ron de Bruin http://www.rondebruin.nl "Stuart" wrote in message ... How do I get a date from a user, via a form, and then validate their entry, please? I currently have textboxes and labels as follows: .......... / ........... / ................ tbDay Lb tbMonth Lb tbYear where "16/05/2005" would be validated, but "30/02/2005" (for example) should not be validated........ don't remember 30 days in February anytime recently. Surely there is an easier way than having to write all the validating code? Regards. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Getting user's Date from a Form
Unfortunately, Excel isn't bothered by 30 Feb 2005
? day(dateserial(2005,2,30)) 2 So I guess you would have to write the validating code. Or, why not use a combobox. Use a single combobox if a reasonable range of dates or use 3 comboboxes that are progressively restrictive based on the preceding entry. Entry should be Year, Month, Day. Or possibly use your current setup, but still make the choices progressive. (I haven't really given that one much thought, but it is probably easier than checking everything). -- Regards, Tom Ogilvy "Ron de Bruin" wrote in message ... It is doing that Stuart Day(DateSerial(Me.text1, Me.text2, Me.text3)) For example if you fill in 2005,2,30 in the textboxes MsgBox Day(DateSerial(2005, 2, 30)) will give you day number 2 So if you test if the day number in the textbox is the same then you know you have a valid date -- Regards Ron de Bruin http://www.rondebruin.nl "Stuart" wrote in message ... Many thanks, but I may not have explained correctly. I wish to let the user specify a date (any date of their choice) but then check it's validity against (eg): it cannot be 30th February it cannot be 32nd December it cannot be 0th any Month etc Hope this is clearer. Regards. "Ron de Bruin" wrote in message ... Hi You can test the day number is the same in the textbox and in the date you create with the three textboxes Use If Day(DateSerial(Me.text1, Me.text2, Me.text3)) =daytextbox then -- Regards Ron de Bruin http://www.rondebruin.nl "Stuart" wrote in message ... How do I get a date from a user, via a form, and then validate their entry, please? I currently have textboxes and labels as follows: .......... / ........... / ................. tbDay Lb tbMonth Lb tbYear where "16/05/2005" would be validated, but "30/02/2005" (for example) should not be validated........ don't remember 30 days in February anytime recently. Surely there is an easier way than having to write all the validating code? Regards. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Getting user's Date from a Form
But just to add, isdate and datevalue appear to be more discerning although
lightly tested: ? isdate("02/30/05") False ? datevalue("02/30/05") raised a type mismatch error. -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... Unfortunately, Excel isn't bothered by 30 Feb 2005 ? day(dateserial(2005,2,30)) 2 So I guess you would have to write the validating code. Or, why not use a combobox. Use a single combobox if a reasonable range of dates or use 3 comboboxes that are progressively restrictive based on the preceding entry. Entry should be Year, Month, Day. Or possibly use your current setup, but still make the choices progressive. (I haven't really given that one much thought, but it is probably easier than checking everything). -- Regards, Tom Ogilvy "Ron de Bruin" wrote in message ... It is doing that Stuart Day(DateSerial(Me.text1, Me.text2, Me.text3)) For example if you fill in 2005,2,30 in the textboxes MsgBox Day(DateSerial(2005, 2, 30)) will give you day number 2 So if you test if the day number in the textbox is the same then you know you have a valid date -- Regards Ron de Bruin http://www.rondebruin.nl "Stuart" wrote in message ... Many thanks, but I may not have explained correctly. I wish to let the user specify a date (any date of their choice) but then check it's validity against (eg): it cannot be 30th February it cannot be 32nd December it cannot be 0th any Month etc Hope this is clearer. Regards. "Ron de Bruin" wrote in message ... Hi You can test the day number is the same in the textbox and in the date you create with the three textboxes Use If Day(DateSerial(Me.text1, Me.text2, Me.text3)) =daytextbox then -- Regards Ron de Bruin http://www.rondebruin.nl "Stuart" wrote in message ... How do I get a date from a user, via a form, and then validate their entry, please? I currently have textboxes and labels as follows: .......... / ........... / ................ tbDay Lb tbMonth Lb tbYear where "16/05/2005" would be validated, but "30/02/2005" (for example) should not be validated........ don't remember 30 days in February anytime recently. Surely there is an easier way than having to write all the validating code? Regards. |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Getting user's Date from a Form
Many thanks to you both.
Had thought in my op that there was some function or udf that I had been unable to find/google search to do this. But it looks as though 'IsDate/DateValue' may well do most of what I need. Thanks again. Regards. "Tom Ogilvy" wrote in message ... But just to add, isdate and datevalue appear to be more discerning although lightly tested: ? isdate("02/30/05") False ? datevalue("02/30/05") raised a type mismatch error. -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... Unfortunately, Excel isn't bothered by 30 Feb 2005 ? day(dateserial(2005,2,30)) 2 So I guess you would have to write the validating code. Or, why not use a combobox. Use a single combobox if a reasonable range of dates or use 3 comboboxes that are progressively restrictive based on the preceding entry. Entry should be Year, Month, Day. Or possibly use your current setup, but still make the choices progressive. (I haven't really given that one much thought, but it is probably easier than checking everything). -- Regards, Tom Ogilvy "Ron de Bruin" wrote in message ... It is doing that Stuart Day(DateSerial(Me.text1, Me.text2, Me.text3)) For example if you fill in 2005,2,30 in the textboxes MsgBox Day(DateSerial(2005, 2, 30)) will give you day number 2 So if you test if the day number in the textbox is the same then you know you have a valid date -- Regards Ron de Bruin http://www.rondebruin.nl "Stuart" wrote in message ... Many thanks, but I may not have explained correctly. I wish to let the user specify a date (any date of their choice) but then check it's validity against (eg): it cannot be 30th February it cannot be 32nd December it cannot be 0th any Month etc Hope this is clearer. Regards. "Ron de Bruin" wrote in message ... Hi You can test the day number is the same in the textbox and in the date you create with the three textboxes Use If Day(DateSerial(Me.text1, Me.text2, Me.text3)) =daytextbox then -- Regards Ron de Bruin http://www.rondebruin.nl "Stuart" wrote in message ... How do I get a date from a user, via a form, and then validate their entry, please? I currently have textboxes and labels as follows: .......... / ........... / ................ tbDay Lb tbMonth Lb tbYear where "16/05/2005" would be validated, but "30/02/2005" (for example) should not be validated........ don't remember 30 days in February anytime recently. Surely there is an easier way than having to write all the validating code? Regards. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
DATE IN TEXT FORM - NEED TO CHANGE IT DATE FORM | New Users to Excel | |||
Cancel user's changes but save other changes | Excel Discussion (Misc queries) | |||
insert a user's name/id | Excel Discussion (Misc queries) | |||
How to autofill Excel form with User's Name (i.e., from Outlook) | Excel Programming | |||
How to autofill Excel form with User's Name (i.e., from Outlook) | Excel Programming |