Data In Form

Discuss the database features
Post Reply
RobmUK
Posts: 1
Joined: Wed Aug 09, 2017 9:52 am

Data In Form

Post by RobmUK »

I'm new to Base, but have created databases in Access before. I'm having trouble with a simple database with a form and subform. I've created two simple tables, one with a machine name, and the second holds information on who used it, on what date, and for how long. On the machine table, I have a serial number, and the machine name. The serial number is an autonumber, with a primary key. The second also has a serial number, but I haven't set a primary key. I set a one to many relationship in Access, and this worked, but I don't know if I've got things right in Base. I created a form, with the machine and serial number on it, and a sub form, for the usage details. I can enter data into the main form, but not the sub form. Can someone suggest where I'm going wrong? Thanks.
Open Office 4 Portable Windows 7
Arineckaig
Volunteer
Posts: 828
Joined: Fri Nov 30, 2007 10:58 am
Location: Scotland

Re: Data In Form

Post by Arineckaig »

Can someone suggest where I'm going wrong? Thanks.
Welcome to the forum.

Much the quickest way to get an answer to your problem is to upload a token copy of your Base file: a token copy has all sensitive data removed but replaced by one or two illustrative token records. It is easier to track down the source of problems with a realistic sample, whereas a description of the file can often be open to misinterpretation.

See here for how to upload a file to the forum.
When this issue has been resolved, it would help other users of the forum if you add the word - [Solved] - to the Subject line of your 1st post (edit button top right).
AOOo 4.1.5 & LO 6 on MS Windows 10 MySQL and HSQLDB
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Data In Form

Post by UnklDonald418 »

I can enter data into the main form, but not the sub form … The second also has a serial number, but I haven't set a primary key.
To enter new data on a Base Form or SubForm it must have a Primary Key because the HSQLDB engine requires a Primary Key to differentiate between records.
When you create a table using the Base Table Design GUI and try to Save it without a primary key it offers to create a Primary Key. Unless you are an advanced designer and understand the implications you should always accept that offer.
You should be able to add a Primary Key to your existing table using Tools->SQL and executing an SQL statement something like

Code: Select all

ALTER TABLE "YourTableName" ADD COLUMN "ID" INTEGER GENERATED BY DEFAULT AS IDENTITY (start with 0) ;
Then make sure your data source for the SubForm includes the ID field. Next add a Numerical control for the ID field to your SubForm. It can be hidden from view but it must exist on your SubForm.
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
Post Reply