Results 1 to 7 of 7

Thread: Storing a date

  1. #1
    Join Date
    Sep 2003
    Posts
    228

    Unanswered: Storing a date

    If the user enters 6/6/2004, how do I store that value as 06/06/2004?
    I want the leading zeroes but, I don't want to require the user to put them in manually but, rather just add them automatically.

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    In the BeforeUpdate event of your date entry field:

    Me.myDateEntryField = Format(Me.myDateEntryField, "dd/mm/yyyy")

    The above Format statement is setup for a "day, month, year" date format. If you want a "month, day, year" format then use:

    Me.myDateEntryField = Format(Me.myDateEntryField, "mm/dd/yyyy")


    This line will modify the date entry before it is saved to table. Play with it...make it look the way you want.



  3. #3
    Join Date
    Sep 2003
    Posts
    228
    I tried your suggestion but the following error came up:

    Run-time error '-2147352567 (80020009)'

    The macro or function set to the BeforeUpdate or Validation Rule property for this field is preventing Microsoft Access from saving the data in the field.

  4. #4
    Join Date
    Sep 2003
    Posts
    228
    In my table design, I have the date format as "Short Date". When I type a date directly into the table with leading zeroes, they get stipped off.

  5. #5
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    just put mm/dd/yyyy into format section of your field.
    ghozy.

  6. #6
    Join Date
    Sep 2003
    Posts
    228
    Thanks. I wasn't aware you could do that.

  7. #7
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    yes you can. the dropdown options are stock options, you can do custom formatting with proper letters.
    ghozy.

Posting Permissions

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