By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,659 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,659 IT Pros & Developers. It's quick & easy.

Text box (Unbound) to Date Type

P: 28
Hi all,

I have a text box in form and it contains date (get value from combo box). Now I want to convert/change this text box to date type.

Is the anyway I can do it?

Thank you so much.
Jan 9 '09 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 2.5K+
P: 2,545
Hi Shimul. To convert the text-based date in your textbox to a date type use the CDate function. Example in VBA:

Expand|Select|Wrap|Line Numbers
  1. Dim SomeDate as Date
  2. SomeDate = CDate(Forms![name of your form]![name of the textbox])
Date/Time values are stored internally as decimal values, with the whole number part the number of days from 1 Jan 1900, and the decimal part the time. CDate converts the text date to its equivalent date type (an elapsed days value essentially), applying the current regional settings for interpretation of the month and day parts.

Jan 10 '09 #2

Expert Mod 15k+
P: 31,487
As Stewart says, there's not a way to make the TextBox control work as a Date control, but if you cast it on use (CDate()) then it should work for you reliably.
Jan 12 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.