GPGeorge
George Hepworth
- Local time
- Today, 06:41
- Joined
- Nov 25, 2004
- Messages
- 3,277
I uploaded the little test accdb. So far as I understand and observe, your description matches what I see.@GPGeorge can you test what happens if you add a single record into a multi record hole? IOW delete 5 records, then fill in the first hole, then add another record manually. IIRC the autonumber picks up after your append and adds one to whatever that PK you just placed in with a query.
PK:
01 to 100 exists
101-105 are a hole
106 - 110 exists.
Use your query to add 101 into the hole. Add a new record allowing the autonumber to do whatever it wants. What is the autonumber value it places into the table? Is it 102, the number after yours? Or is it 111, the number it would have been if you had not inserted your record?
I seem to remember that it adds 102, 103, 104 and 105. When it runs into 106, it "jumps" to the last (highest) value plus 1. In this case it would go from 105 to 111.
Is that clear as mud? I haven't actually done any of this for 15 years so maybe my memory is hazy.
The query inserts a record into the table using the specified value for the AutoNumber PK field, with one exception. That is, if the attempted insertion would duplicate an existing PK value, it fails. As we'd expect.
When you resume adding records normally, i.e. in a datasheet or using a form, or appending a record without specifying the PK, it picks up from that last entered value, regardless where it falls in the overall sequence, and regardless of how it was inserted, via the query or via a form, etc.
For example, I append a record with PK value 20000 specified using the query. Then I append a record with PK value 10000 using the query.
When I add another record, using the datasheet view of the table, the assigned PK is 10001, the next value following the most recently used value.