Page 1 of 1

How to implement what MS calls "Autonumber" key field?

PostPosted: Tue Feb 06, 2018 2:26 am
by JSSchiavo
FOrgive me if this is addressed here somewhere, but I didn't find it.

I'm steeped in the MS "way", and now, converting to OpenOffice, I want to define a table with a primary key that is incremented automatically with each record added: what MS calls "Autonumber".

I need to create a database for folder files, with an integer file number ("ID") that is simply applied by the system.

I haven't found anything similar as yet. Can you direct me?

Many thanks for the help.

Stephen

Re: How to implement what MS calls "Autonumber" key field?

PostPosted: Tue Feb 06, 2018 4:26 am
by robleyd
The term used by Base may be either autoincrement or autovalue - see the offline help and search primary keys

Re: How to implement what MS calls "Autonumber" key field?

PostPosted: Wed Feb 07, 2018 12:52 am
by UnklDonald418
One way is to use an SQL command to alter your table.
If your table already has an "ID" integer field as the Primary Key and there are no records in the table then edit the table name and if your table already contains records with previously assigned values for "ID" then you need to replace the 0 with a new start value. Then go to Tools->SQL and execute
Code: Select all   Expand viewCollapse view
ALTER TABLE "YourTableName" ALTER COLUMN "ID" INTEGER GENERATED BY DEFAULT AS IDENTITY (start with 0);

Re: How to implement what MS calls "Autonumber" key field?

PostPosted: Sun Feb 11, 2018 2:04 pm
by Nocton
In your table, select Field Type 'Integer' and then in the Field Properties select 'AutoValue = 'Yes'.

Re: How to implement what MS calls "Autonumber" key field?

PostPosted: Mon Sep 16, 2019 10:29 pm
by rwzelnick
>>> In your table, select Field Type 'Integer' and then in the Field Properties select 'AutoValue = 'Yes'.
i tried that several times with an empty database but after I save the table and go back to Edit it, Autoumber is set OFF, and is grayed out so there's no way to change it. I had to use the SQL statement ALTER... given elsewhere in this thread. I had to put data in the table, then look at the bottom index number in it, and then put that number
+ 1 in that SQL statement, as they show. It worked.

Re: How to implement what MS calls "Autonumber" key field?

PostPosted: Tue Sep 17, 2019 9:29 am
by Nocton
I think you must be using a 'split' database. In that case you have to use a SQL statement or copy the table to a normal, temporary, 'embedded' database, edit it as required, and then copy it back to your database.