Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
DATE IN TEXT FORM - NEED TO CHANGE IT DATE FORM SSJ New Users to Excel 3 October 27th 06 08:34 PM
Cancel user's changes but save other changes [email protected] Excel Discussion (Misc queries) 1 December 19th 05 12:09 PM
insert a user's name/id benb Excel Discussion (Misc queries) 1 January 10th 05 08:05 PM
How to autofill Excel form with User's Name (i.e., from Outlook) Kind writer/user/programmer Excel Programming 1 January 5th 05 11:10 PM
How to autofill Excel form with User's Name (i.e., from Outlook) Kind writer/user/programmer Excel Programming 0 January 5th 05 10:38 PM


All times are GMT +1. The time now is 12:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"