Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Oct 2002
    Location
    Sayre, Pennsylvania, USA
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date/Time Field-Typing just year for date. (Access 2000)

    I have a date field and all I want to enter is the Year. I have the format ok, where it only shows the Year, but I still have to enter a full date 01/01/03. How can I just type in a Year.

    Thanks,
    Deb

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Date/Time Field-Typing just year for date. (Access 2000)

    In the first place, ask yourself whether you really need a Date/Time field. If you just want to store a year, why not use an Integer field?

    If you *do* need a Date/Time field, you can't just enter a year - Windows doesn't recognize it as a valid date. You can get around this in a form (not in a table or query, but you shouldn't use tables or queries for data entry anyway). Place an unbound text box on the form (that is, the Control Source of the text box must be empty), set its Format property to 0 (to ensure numeric entries) and fill the Date/Time field in the AfterUpdate event of the text box.

    Let's say that your Date/Time field is named MyDate, and that the text box is named txtYear. The AfterUpdate event procedure would look like this:

    Private Sub txtYear_AfterUpdate()
    MyDate = DateSerial(txtYear, 1, 1)
    End Sub

    If you don't know how to create an event procedure, post back to get detailed instructions.

  3. #3
    4 Star Lounger
    Join Date
    Oct 2002
    Location
    Sayre, Pennsylvania, USA
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date/Time Field-Typing just year for date. (Access 2000)

    Thanks for resonding Hans. I thought about using integers. I think I'll just do that, but it's good to know the event procedure. I know what they do and all, I just don't know VB yet.
    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •