Results 1 to 3 of 3
  1. #1
    Eddy Sincere is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Location
    Carson City, NV
    Posts
    114

    Auto Increment / Auto Number without using standard "autonumber" field

    Can I create an auto increment field based off the value of the AutoNumber field? My table has an AutoNumber filed as the PK. Because MS Access always increments it ensures the field value is unique. I want to use this as the base for creating the value of a new field ([Field1], e.g...



    [Field1] = [AutoNumber] + 10000

    If I had three records, the value of [Field1] would be 10000, 10001 and 10002.

    This calculation can't happen until the record becomes active and Access assigns a value to the [AutoNumber] field. I was thinking I may be able to write some VBA on the "After Update" event for the record that runs the calculation and inserts the data into [Field1]? Is this possible or am I stuck using the NZ(DMax) option?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,522
    no, autonumber is the only autonumber.
    you CAN write code to build your own, but its not really auto at that point.
    Dmax is it.

    Autonum is a passive mindless method that works. Why make extra work for yourself?

  3. #3
    Eddy Sincere is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Location
    Carson City, NV
    Posts
    114
    Thanks for the response. I was hoping that was a trick I didn't know about.

    In answer to your question, I have an Autonumber field as the PK, however, per the good database practices, it doesn't "mean" anything. The user never sees it and it's only purpose is to serve as the PK. For this application I wanted to create a number for vendors, is unique and has some logic built into it. The Autonumber function but then I start to deviate from the good database practices and that's usually not a good idea in the long term. I'll just use the DMax.

    Cheers!

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

Similar Threads

  1. Replies: 4
    Last Post: 06-06-2014, 08:50 AM
  2. Replies: 1
    Last Post: 10-16-2013, 09:41 AM
  3. Auto increment on existing number column
    By lcsgeek in forum Programming
    Replies: 1
    Last Post: 04-15-2013, 11:27 AM
  4. Increment a number by "1"... once everyday
    By MikeWooZ in forum Reports
    Replies: 10
    Last Post: 12-01-2011, 01:41 PM
  5. Replies: 5
    Last Post: 11-12-2010, 12:10 PM

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