form to update table

Creating and using forms
Post Reply
prickles
Posts: 25
Joined: Sat Jun 07, 2008 4:19 am

form to update table

Post by prickles »

I have a table called "cows" ,showing animal details . age , breed , tag number . i am wanting to set up a form to update these details . Tag number is set as primary key ,( so all tags must be unique)
cant get form to update detail when entering new detail for tag . reports errr "violation unique constraint SYS_PK_47: duplicate values for column 'TAG NUMBER' in statement [UPDATE "cows"SET"age"=?,"cow number"=?WHERE"cow number"=?] If i change the primary key i get several animals with same tag number but differing details .
any help appreciated
New Database Herd.odb
(20.95 KiB) Downloaded 217 times
OOo 2.3.X on Ms Windows XP
User avatar
squenson
Volunteer
Posts: 1885
Joined: Wed Jan 30, 2008 9:21 pm
Location: Lausanne, Switzerland

Re: form to update table

Post by squenson »

As a cow can have several calves, you cannot use, in the table calf, the cow number as a primary key, which must be unique by definition. I suggest you use the field Calf ID as a key, as I guess this ID is unique. To do so, simply edit the table calf, right click on Cow Number and deselect Primary Key, the right-click on the field Calf ID and select Primary key.

If I may, I also suggest that you do not use a field containing the age of the cow, or else you will have to update this field every year.
LibreOffice 4.2.3.3. on Ubuntu 14.04
prickles
Posts: 25
Joined: Sat Jun 07, 2008 4:19 am

Re: form to update table

Post by prickles »

tried above thankyou . still having problems with it not updating the data but coming back with same error . What have i not set right . Or will forms not updat current data , only enter new.
Cow number 1, life id 1 breed 1... want to replace with
Cow number 1, life id 2 breed 1...or
cow number 1, life id 1, breed 2.
the only constant will be cow number .
thankyou
Attachments
New Database Herd.odb
(11.6 KiB) Downloaded 206 times
Post Reply