Results 1 to 4 of 4
  1. #1
    kbahr99
    Guest

    Automatic Year fill in

    Hi All,

    I have a form that I want to assign a number to an instance of the form (like a record ID). My user wants the record ID to be in the format of YYYY999 where the numbers are auto numbers rather than dates. For example, the first record would be 2001001. Does anyone have any ideas on how to easily do this and is it advisable that I use it as my primary key rather than a hidden autonumber field that can be a primary key.

    Thanks for your time.

  2. #2
    Lounger
    Join Date
    Apr 2001
    Location
    KY USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatic Year fill in

    The only way I could see to do this would be to add an autonumber to the table, then require a "Save" button to be clicked to save the record. The save would save the record (thus creating the record number on the autonumber field) then it would

    YearRecNum = right(date(),4) & txtAutonum
    docmd.runcommand.accmdrefresh

    where YearRecNum is the field concatenating the Autonumber and the Year off of the date field. For this to work the regional settings MUST have the date set to mm/dd/yyyy.

    This, however, may not solve your problem. My thoughts are that your user wants to be able to look at a record and say "This is the 135th Account for 2001.", which may not be the case. An autonumber field will not use the same number twice, so if a record was added by mistake then deleted, the numbering system is then off. Likewise, it will not reset 1-1-2002. You might want to verify the user's goal in establishing this key. Then again I might be entirely off, and the above solution could be exactly what you want.

    Hope this helps.

    Jeff

    (solution was for an Access 97 SR2 configuration)

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

    Re: Automatic Year fill in

    Take a look at <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showflat.pl?Cat=&Board=acc&Number=37088&page=0&vie w=collapsed&sb=5>this thread</A> for more ideas.
    Charlotte

  4. #4
    kbahr99
    Guest

    Re: Automatic Year fill in

    Thank you for your reply!! <img src=/S/smile.gif border=0 alt=smile width=15 height=15> <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

Posting Permissions

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