Results 1 to 4 of 4
  1. #1
    izamac is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2015
    Posts
    1

    Question I want to control and automate my number sequence in Access 2010

    I do not want to use AutoNumber to generate my Stock Control Number. I need to somehow automatically generate a number so that when I enter data and then make an error it does not mess up the numbering system like AutoNumber does.
    I am a novice who is will to try to do what it takes to get this going properly. I cant find anything online relating to Access 2010

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    AutoNumber CANT mess up. Tho if you want some specific number, please advise.
    what format?

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Are you looking for an alternative to AutoNumber? The hard part is making sure you do not edit an existing record's sequential number. You have to find a place for your code where it will fire whenever a new record is created. Maybe something like this.


    Code:
    If IsNull(Me.ID.Value) And Me.NewRecord = True Then
        Dim lngUnique As Long
        
        lngUnique = DMax("ID", "Table1")
        lngUnique = lngUnique + 1
        
        Me.ID.Value = lngUnique
        
            If Me.Dirty Then
                Me.Dirty = False
            End If
    End If

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I think you want a hybrid of itsme's suggestion and an autonumber.

    Autonumber can not be overwritten or messed up, that's what you want to avoid any possibility of having.

    So if you had a table where, on the third record you had entered something that was wrong you would have something like

    Code:
    tblTest
    PK  PartNumber  PartDesc
    1   1           Part Number 1
    2   2           Part Number 2
    4   3           Part Number 3
    This way you are maintaining the integrity of a PK (something that you know will not be changed over time).

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 11-30-2014, 12:46 PM
  2. Sequence number in query use a starting number
    By fgwapo in forum Programming
    Replies: 1
    Last Post: 09-21-2014, 12:44 AM
  3. Macro code: Automate Select Query Sequence
    By Ace2014 in forum Modules
    Replies: 2
    Last Post: 06-13-2014, 09:21 AM
  4. Replies: 3
    Last Post: 01-23-2014, 01:54 PM
  5. Replies: 2
    Last Post: 11-21-2011, 10:48 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