![]() |
controlling date entry in a text box
We have a form where the user enters the date a sample was taken. The
date is then pasted into a worksheet column that has been formatted as a date in the x/xx/xx format. If the user types x/xx/xxxx (2003 not 03) the date does not appear correctly in the worksheet. How can I force dates to be entered to the x/xx/xx format when typed into the data entry form? OR How can I check the format of the text box (txtDateSampled.text) after it has been typed on the form to see the format, and change it to the format of the destination worksheet column (entered with 4 digits for the year instead of the 2 we need?? something like: If txtdateSampled.text has 4 digits for the year then make txtDateSampled have 2 digits for the year. End If I thought of using right or mid BUT could not think of a simple way to do it other than a long complicated If statement. I know there must be an easy way. Any help would be greatly appreciated. Thanks, BB ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
controlling date entry in a text box
varMyResult = Format(txtDateSampled.text,"dd/mm/yy")
Obviously you can use your own format string ("x/xx/xx" will not work though!) P "captbluefin" wrote in message ... We have a form where the user enters the date a sample was taken. The date is then pasted into a worksheet column that has been formatted as a date in the x/xx/xx format. If the user types x/xx/xxxx (2003 not 03) the date does not appear correctly in the worksheet. How can I force dates to be entered to the x/xx/xx format when typed into the data entry form? OR How can I check the format of the text box (txtDateSampled.text) after it has been typed on the form to see the format, and change it to the format of the destination worksheet column (entered with 4 digits for the year instead of the 2 we need?? something like: If txtdateSampled.text has 4 digits for the year then make txtDateSampled have 2 digits for the year. End If I thought of using right or mid BUT could not think of a simple way to do it other than a long complicated If statement. I know there must be an easy way. Any help would be greatly appreciated. Thanks, BB ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
controlling date entry in a text box
Thank you's to Phobos for the quick answer!!!!
------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 03:41 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com