- Local time
- Today, 13:33
- Joined
- Feb 19, 2002
- Messages
- 47,054
-- Please do not give that advice in Access forums. Most of the people who post here are not sophisticated developers and do not understand the underlying technology. The autonumber is simply a number generator. The default is to generate sequentially ascending numbers. Except for the bugs that have been noted, this works as expected. It is the unique index or primary key constraint that prevents the insertion of duplicates. The autonumber in and of itself does not do that. In an Access table that has an autonumber field, if it is not specified as the primary key, there are bugs that can cause it to lose its seed.And I contend that an index on such column is totally worthless and wasteful. It consumes space and slows-down inserts.
I have. Since you seem to be able to, please post a working example so we can all learn something.You seem to be under the impression that you can't enforce RI with a non-primary candidate key. I don't know why you think that. I know you can enforce RI against non-primary keys in Jet and you can do the same with any DBMS that supports Standard SQL, including Oracle, SQL Server and MySQL. A foreign key constraint can reference any key* and the logic and behaviour is exactly the same whether that key happens to be "primary" or not. I suggest you try it out for yourself.
@Others,
I did try the example syswizard suggested and found the seed bug using A2010. Compacting resets the seed correctly. I have not run into this in practice since it is rare that I append rows with existing autonumber values and most of my BE's are SQL Server anyway.