Create duplicate records based on field value

Creating and using forms
Post Reply
christos73
Posts: 16
Joined: Sat Jan 20, 2018 4:26 pm
Location: Greece

Create duplicate records based on field value

Post by christos73 »

Hello forum!

I have an table : tblDetails that has the following fields named :

Barcode (Number)
Price1 (Number)
Price2 (Number)
etc...

What i want is when i enter data in my form, suppose i enter in Price1 the value :"1.99" i want to be copied - mirrored in Price2 field (automatically.

So when i step in Price2 i would leave it unchanged or i'll enter what value i like to.

Does anyone knows how i can mirror Price1 value onto Price2?

Thank you and have a nice day!
Apache OpenOffice 4.1.7 - -
User avatar
Villeroy
Volunteer
Posts: 31270
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Create duplicate records based on field value

Post by Villeroy »

Make "Price2" optional (nullable) but not "Price1". Then use the value of "Price1" when "Price2" is missing.

Code: Select all

SELECT "Table".*, COALESCE("Price2","Price1") AS "P2" FROM "Table"
selects all columns plus the "true Price2" AS "P2".
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
christos73
Posts: 16
Joined: Sat Jan 20, 2018 4:26 pm
Location: Greece

Re: Create duplicate records based on field value

Post by christos73 »

Hello Villeroy,

See my screenshot:

So i'am looking something like this https://ask.libreoffice.org/en/question ... r-a-field/ but it' doesn't work in base.
Attachments
oo_question2.png
oo_question2.png (4.88 KiB) Viewed 3779 times
Apache OpenOffice 4.1.7 - -
User avatar
Villeroy
Volunteer
Posts: 31270
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Create duplicate records based on field value

Post by Villeroy »

Just keep it blank if the prices are the same. Add some explanatory text to the label such as "(blank if same price)"
Attachments
default_if_blank.odb
(12.15 KiB) Downloaded 254 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
christos73
Posts: 16
Joined: Sat Jan 20, 2018 4:26 pm
Location: Greece

Re: Create duplicate records based on field value

Post by christos73 »

Ok it works through the query. But the field "V2" still remains empty in Tables.
I need the "Value2" from Query1 to be transferred into "V2" field.
I must make relation between these two fields!

And query is not the solution for me. Because when the second field which is ""Price2" has different cost value, if i run the query it will replaced by Price1 which I don't want.

Thanks for your time!
Apache OpenOffice 4.1.7 - -
Post Reply