Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Mar 2001
    Location
    Atlanta, Georgia, USA
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Best way to handle a date field? (Access 2000 SR1)

    This one will probably create a long discussion. I have a 'normal' date field that I currently have some code hooked in so that the user can increment and decrement the date using the '+' and '-' keys. However, I was wondering if there was some way to make the field more generic, so the end user can do more than that - for example, enter the date as a string: Sept 27, 1950 and have it translated into the localized date.

    Localizattion is not a necessity, but it would be nice to have the date more free-form.

    Any ideas?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Best way to handle a date field? (Access 2000 SR1)

    Yes, don't. Pick a date format like medium date (dd-mmm-yy) and stick with it. That is a generally accepted and understood format pretty much anywhere so there will be no confusion. The user can still enter a date in their local format if you don't stick some kind of ugly input mask on the field, but the display will be dd-mmm-yy and the underlying field will still be just date/time.
    Charlotte

  3. #3
    Star Lounger
    Join Date
    Mar 2001
    Location
    Atlanta, Georgia, USA
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Best way to handle a date field? (Access 2000 SR1)

    Thanks! That gave me the best of both worlds. I can let the user enter the dates in multiple formats, and still use the +. -, pgup and pgdn functions like Quicken. It should make things easier for our customers.

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Best way to handle a date field? (Access 2000 SR1)

    Just one small caution related to Charlotte's recommendation. If you are likely to be entering dates that are around the default assumption date, then you should probably use a four digit year value. For example if a user wants to enter a person's birthdate, and it happens to be 1/1/1928, if you enter it in a two digit format, it will be presumed to be 1/1/2028. You can get more details in the help file under "Format Property - Date/Time Data Type"
    Wendell

  5. #5
    Star Lounger
    Join Date
    Mar 2001
    Location
    Atlanta, Georgia, USA
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Best way to handle a date field? (Access 2000 SR1)

    Definitely using four digits for the year! Thanks for the tip.

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Best way to handle a date field? (Access 2000 SR1)

    Be careful of PgUp and PgDown in a bound form. Depending on your form settings, that can move the user to a new or previous record unless you're trapping the key down events to prevent that.
    Charlotte

  7. #7
    Star Lounger
    Join Date
    Mar 2001
    Location
    Atlanta, Georgia, USA
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Best way to handle a date field? (Access 2000 SR1)

    Keydown is exactly what I'm trapping. Not only can the user enter the date in numerous formats, but it makes changing the date extremely simple. I was surprised how elegant it makes the app look.

Posting Permissions

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