Results 1 to 2 of 2

Thread: Concentating Primary Keys

  1. #1
    Join Date
    Sep 2003
    Location
    North Yorkshire
    Posts
    1

    Question Concentating Primary Keys

    I have an access database which generates (Through autonumber) the primary key. However, I would like to proceed the key with the year and expand the record to read as a four figure number, hence record 1 becomes record 03 - 0001

    I do have a date field in the database and would be happy to use that however the date is a full date format (dd/mm/yyyy).

    I would also like the key to start again on the 1st Jan so the first record of 2004 would become 04 - 0001.

    Any ideas, suggestions, mild insults would be most welcome.

    Terry

  2. #2
    Join Date
    Sep 2003
    Location
    UK
    Posts
    14
    Try This ...

    SELECT Format([DateField],"yy") & "-" & Format(CStr([AutoID]),"0000") AS Expr1
    FROM tblName;

Posting Permissions

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