Auto number & .AddNew problem.

GaelicFatboy

Registered User.
Local time
Today, 18:53
Joined
Apr 17, 2007
Messages
100
Morning everyone,

I've noticed a wee problem with a table employing an "ID" auto number field as the only primary key. The table holds six additional pieces of design information for an enginnering application. This table is used in a query to display the data on a split form.

I've added code so that a new record is entered when the form is opened, the code line reads:

Me.Recordset.AddNew

Would anyone know why once the new record has been entered the ID number has skipped the next number in the sequence and used the one after that, for emample.

Before record is added the maximum ID number is 50, after record is added there is no ID record for 51, instead 52 is the next number.

Is my use of .AddNew incorrect, or is there another way to focus a split form onto a new record as soon as it's opened? I'm running Access 2007 on Windows 7.

Cheers

D
 
An autonumber only gives you uniquenes NOT nessecerly sequence numbers.

If it's sequence you need, you must generate it yourself. One way is to use the DMax function and add 1 to it. The problem with that is in a multi-user enviroment it is a chance to get dupliactes, so you must call the function at the last possible moment when you insert it to the table.

Hope this helps.

JR
 
I've used the DMax method on other applications, but the database I'm writing is designed for multi users so to avoid duplication I opted for an autonumber.

Cheers anyway

D
 

Users who are viewing this thread

Back
Top Bottom