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
How to implement what MS calls "Autonumber" key field?
How to implement what MS calls "Autonumber" key field?
OpenOffice 4.1.4 on Windows 10
Re: How to implement what MS calls "Autonumber" key field?
The term used by Base may be either autoincrement or autovalue - see the offline help and search primary keys
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
-
- Volunteer
- Posts: 1549
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: How to implement what MS calls "Autonumber" key field?
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
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
ALTER TABLE "YourTableName" ALTER COLUMN "ID" INTEGER GENERATED BY DEFAULT AS IDENTITY (start with 0);
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Re: How to implement what MS calls "Autonumber" key field?
In your table, select Field Type 'Integer' and then in the Field Properties select 'AutoValue = 'Yes'.
OpenOffice 4.1.12 on Windows 10
Re: How to implement what MS calls "Autonumber" key field?
>>> 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.
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.
Open Office 4.0 on Win 7
Re: How to implement what MS calls "Autonumber" key field?
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.
OpenOffice 4.1.12 on Windows 10