Error inserting a new record (Null)

Creating tables and queries
Locked
Kzneft
Posts: 8
Joined: Fri Jul 24, 2020 1:33 am

Error inserting a new record (Null)

Post by Kzneft »

Granted I am a new to OpenOffice, but even Access was not this hard
Anyway I have my database created with help from this forum that I originally had in Access. I even created a nice form for inputting information. I can search, modify existing customers, but for the life of me it won't let me create a new record. Get the error "Attempt to insert null into a non-nullable column: column: ID table: CustomerT in statement [INSERT INTO "CustomerT" ( "CompanyName","GibbsCAMCustomer") VALUES ( ?,?)] everytime I try to create a new record. Get the same error if I go to the Table and try to create new record. Can someone tell me what's going on? I have searched for this error, but all I see is from users from 10+ years ago.
OpenOffice 4.1.7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Error inserting a new record (Null)

Post by Villeroy »

Kzneft wrote:Granted I am a new to OpenOffice, but even Access was not this hard
MS Access is a multi-million Dollar product of the 90ies designed to serve amateurs. MS Access has a bigger footprint than this whole office suite where the Base component weighs no more than 30 MB.
The error message is clear and I could not explain it better. YOU are the database developer. YOU created table "CustomerT" with some mandatory field(s) not covered by your input form.
You can still use MS Access and use an existing MS Access database with OpenOffice. Database tools like Access and Base are designed to re-use existing databases.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Kzneft
Posts: 8
Joined: Fri Jul 24, 2020 1:33 am

Re: Error inserting a new record (Null)

Post by Kzneft »

That didn't help me at all.
OpenOffice 4.1.7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Error inserting a new record (Null)

Post by Villeroy »

There is a table "CustomerT" where you try to insert a new row with 2 values for "CompanyName" and "GibbsCAMCustomer". The error indicates that there is a missing value for a mandatory, not nullable field. If both fields "CompanyName" and/or "GibbsCAMCustomer" are provided, some other field(s) in the same table may not accept missing values. A primary key perhaps? Make it auto-increment.
---------
In the attached database, all fields are mandatory, not nullable.
The primary keys ("ID") auto-increment.
The form accepts new records if you provide both, a name and a GibbsCAMCustomer. If any value is missing, you get the same error message.
Attachments
t102782.odb
One-to-many relation
(12.03 KiB) Downloaded 289 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
UnklDonald418
Volunteer
Posts: 1549
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Error inserting a new record (Null)

Post by UnklDonald418 »

Looking at the error message, it actually states that the problem is occurring with regards to the Column named "ID".
Right click on the table CustomerT and select Edit to open the Table Design GUI.
Select the Field Name ID. It should have a small yellow key icon on the left, designating it as the Primary Key. It should have a Field Type of Integer.
Next look at the Field Properties pane of the GUI window and make sure Auto Value is Yes.
Exit and Save if any changes were made.

If that doesn't resolve the problem then look at your form, and make sure the "ID" column appears somewhere on the form. It can be hidden from the user, but it must appear on the form at least in the Design mode.
 Edit: It just occurred to me that if your table already has a number of records with a value in the "ID" field., and Auto Value isn't already set to Yes for "ID", changing it may not work.
If that's the case, note the highest value found in the ID field in "CustomerT" then substitute
that value +1 for XXX in the following SQL statement.

Code: Select all

ALTER TABLE "CustomerT" ALTER "ID"  GENERATED ALWAYS AS IDENTITY (start with XXX) ;
then execute that statement at Tools>SQL
Whenever you execute a statement there you are bypassing Base and working directly with the HSQL database engine, so you must inform the Base front end of those changes by selecting
View>Refresh Tables
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
Locked