Text box (Unbound) to Date Type

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shimul
    New Member
    • Nov 2008
    • 28

    #1

    Text box (Unbound) to Date Type

    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.
    Shimul
    Last edited by Frinavale; Jan 9 '09, 09:45 PM. Reason: Moved to Access Answers form Insights
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Hi Shimul. To convert the text-based date in your textbox to a date type use the CDate function. Example in VBA:

    Code:
    Dim SomeDate as Date
    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.

    -Stewart

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      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.

      Comment

      Working...