Board index » delphi » ????? ACCESS Autonumber error, adds more then 1 ??????

????? ACCESS Autonumber error, adds more then 1 ??????

I am using Delphi 4, BDE 5.01 with the native ACCESS driver. Ok no
problems there.
Then I tried to add a record to a table who's prim. key is of the
autonumber type, it adds the key but leaves holes in it, it doesn't add
1, but 2 or 3. e.g. Last record id=3, add a new one, the ID will be 5 or
6 and not 4.
While with an other table all goes well, no holes in my prim. key
numbering.

Now I also tried the ODBC version, and all goes well, no problems with
key number skipping, so it cant be my ACCESS tables.

I also found an other difference between the native and the ODBC version.
If you look at <Table Name>-->Indices-->PrimaryKey-->Fields in the
SQL Explorer from Delphi it states a field: 'code' wich is just an
attribute and not the ID (prim key) of that table, so thats wrong!
But with the ODBC connection it states the ID, wich it should!!!!

Does anybody know what's wrong?????

Maybe a usefull tip, Indexes wont work if you have spaces in an attribute
name, Delphi gives an error!

Anyway thanks,

Ido de Lepper
ilep...@fac.fbk.eur.nl

 

Re:????? ACCESS Autonumber error, adds more then 1 ??????


Quote
ilepper wrote in message ...
>I am using Delphi 4, BDE 5.01 with the native ACCESS driver. Ok no
>problems there.
>Then I tried to add a record to a table who's prim. key is of the
>autonumber type, it adds the key but leaves holes in it, it doesn't
add
>1, but 2 or 3. e.g. Last record id=3, add a new one, the ID will be 5
or
>6 and not 4.
>While with an other table all goes well, no holes in my prim. key
>numbering.

This is a known bug(??). It happens when you have some fields in the
table that have default values or so I am told. I don't use default
values in the tables but rather assign them myself in the OnNewRecord
events for my tables. This could fix your problem also.

Quote

>Now I also tried the ODBC version, and all goes well, no problems
with
>key number skipping, so it cant be my ACCESS tables.

>I also found an other difference between the native and the ODBC
version.
>If you look at <Table Name>-->Indices-->PrimaryKey-->Fields in the
>SQL Explorer from Delphi it states a field: 'code' wich is just an
>attribute and not the ID (prim key) of that table, so thats wrong!
>But with the ODBC connection it states the ID, wich it should!!!!

Don't use the IndexFieldNames for Access tables. Use the IndexName
property instead.

Woody

Re:????? ACCESS Autonumber error, adds more then 1 ??????


This is a known problem that occurs when you have default values defined for
any of the fields in the table.

--
Bill Todd
(Sorry but TeamB cannot answer questions received via email)
(Remove nospam from my email address to contact me for any other reason)

Other Threads