Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    RustyRick is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Location
    NW Alberta
    Posts
    53

    Auto Number Custome incremental

    Is it possible to force the Key number to start with my own CUSTOM Number then Auto up one (1) incrementally with every new record? If so how?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,893
    It is possible to set the start number for autonumber field but preventing gaps in sequence is difficult. If value has meaning to users then autonumber field may not be appropriate for your situation. Generating custom unique identifier is a common topic. DMax() function can be used to generate value for a simple counter.

    Nz(DMax("fieldname"),0)+1
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    RustyRick is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Location
    NW Alberta
    Posts
    53
    Whats a good alternative to the fact that every table has as a PRIMARY KEY and Auto Number starting at "1", and incrementing up?

  4. #4
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Use a long integer field instead of autonumber and the code June suggested.

  5. #5
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,563
    Hi

    What June is suggesting is the correct way to do this.

    The Autonumber would normally be hidden as it should have no meaning to the User.

    The the additional Field which you want to show on the Form would always increment by 1 whenever a new record is added.

  6. #6
    RustyRick is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Location
    NW Alberta
    Posts
    53
    thanks Ya'll. Where do I place Nz(DMax("fieldname"),0)+1 I'm pretty green at this stuff.

  7. #7
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,563
    Hi

    That would go in the Before Update of the Form

  8. #8
    RustyRick is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Location
    NW Alberta
    Posts
    53
    Super. Thanks. I think I'm in over my head.

  9. #9
    RustyRick is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Location
    NW Alberta
    Posts
    53
    Related to this, is it OK to have tables with only one (1) column? Therefore only 1 item is the Primary Key?

  10. #10
    RustyRick is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Location
    NW Alberta
    Posts
    53
    Related to this, is it OK to have tables with only one (1) column? Therefore only 1 item is the Primary Key?

  11. #11
    RustyRick is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Location
    NW Alberta
    Posts
    53
    Sorry I didn't mean to repeat myself.

    I don't have a "Long Interger" field available in the drop-down list?

  12. #12
    RustyRick is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Location
    NW Alberta
    Posts
    53
    Another dumb question. Every time I open "Create a New Table" the automatic field is already populated with an "ID and AutoNumber". Is it necessary to keep that? Or have it in a Table?

  13. #13
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Quote Originally Posted by RustyRick View Post
    Sorry I didn't mean to repeat myself.

    I don't have a "Long Interger" field available in the drop-down list?
    Select "number" in the drop down list then in the properties you'll select the number type, in this case long integer.

    Quote Originally Posted by RustyRick View Post
    Another dumb question. Every time I open "Create a New Table" the automatic field is already populated with an "ID and AutoNumber". Is it necessary to keep that? Or have it in a Table?
    It's not necessary. Delete it and set your new number field as primary key.

    Why do you need it this way? It's generally advised against and being a beginner you're going to be making things more difficult and possibly introducing a source of errors.

  14. #14
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,563
    Hi kd2017

    I note your comment regarding deleting the Autonumber Primary Key that is always presented when creating a New Table.

    Why would you want to delete this??

    Quite a lot of developers would disagree with this suggestion.

  15. #15
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,893
    It may not be necessary but it also doesn't hurt if it's there.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. ID autonumber or incremental number in VBA
    By MadTom in forum Database Design
    Replies: 3
    Last Post: 12-02-2019, 04:45 PM
  2. Replies: 6
    Last Post: 09-17-2017, 07:20 PM
  3. Replies: 3
    Last Post: 06-08-2017, 08:03 PM
  4. Replies: 11
    Last Post: 11-11-2014, 06:04 PM
  5. Incremental Number in a Query
    By jmauldin01 in forum Access
    Replies: 5
    Last Post: 01-01-2014, 01:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums