Results 1 to 3 of 3

Thread: AutoNumber

  1. #1
    Mary Ann Guest

    Default AutoNumber

    I would like an auto number followed by the year ie 12000, 22000...122000...1502000. Is that possible in Access?

  2. #2
    Join Date
    Dec 1969

    Default RE: AutoNumber

    There is always a way to do something.<BR><BR>My sugesstion, (which may not be the only correct one) would be that you pull a recordset from sql (ie: Select Max(AutoNumberField) from table) if your rst is empty then add one to db, else just add one onto the number in your recordset!<BR><BR>Like so....<BR><BR>&#039;first get year<BR>set objdate = now()<BR>set year = objDate.getFullYear(); (This is JScript Code, not sure what VBScript is)<BR><BR>SQL = "Select Max(AutoNumberField) from Table"<BR>, conn, 3, 3)<BR><BR>if Rst.eof then<BR>Rst.addnew<BR>Rst("AutoNumberField") = 1 & year<BR>else<BR>Set Number = r<BR>Rst("AutoNumberField")<BR>Number = Number+1<BR>Number = Number & year<BR>Rst.addnew<BR>Rst("AutoNumberField") = Number<BR>Rst.update<BR>End if<BR><BR>HTH<BR>Dave<BR>

  3. #3
    Mary Ann Guest

    Default RE: AutoNumber

    Thanks so much!!!!

Posting Permissions

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