[Solved] Calculation based on results of 2 other fields

Creating and using forms

[Solved] Calculation based on results of 2 other fields

Postby Maax555 » Mon Sep 10, 2018 2:50 pm

Hi, I have a form which requires a simple calculation to be shown on the form (used to quickly estimate a value).
So the used will input a number in field A, field B will be a result of the field chosen from a ListBox and field C will be (A * B).
The form does not need to store the result as it is only an estimate. The user can then choose to use the estimate by entering this manually in another field which will be stored. I was thinking that a Viewtable from a query may be the way ahead but despite searching the forum nothing has helped.
Is there a way on performing a simple calculation as mentioned above? I will also be looking to use other calculations as I progress which should be along the same lines as this.

many thanks
Last edited by Maax555 on Wed Sep 12, 2018 12:14 pm, edited 1 time in total.
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
Maax555
 
Posts: 127
Joined: Tue Mar 28, 2017 11:56 am

Re: Calculation based on results of 2 other fields in form

Postby Villeroy » Mon Sep 10, 2018 4:01 pm

Form source type: SQL or Query
Source: SELECT *, "A" * "B" AS "AxB" FROM "Table" (or the name of the query with this SQL)
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26733
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Calculation based on results of 2 other fields in form

Postby Maax555 » Tue Sep 11, 2018 4:14 pm

Villeroy wrote:Form source type: SQL or Query
Source: SELECT *, "A" * "B" AS "AxB" FROM "Table" (or the name of the query with this SQL)


OK, so i can get a query to calculate the desired result. Cant get the result to show in the form yet, but still trying.

Thanks Villeroy, very helpful as always :-)
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
Maax555
 
Posts: 127
Joined: Tue Mar 28, 2017 11:56 am

Re: Calculation based on results of 2 other fields in form

Postby Villeroy » Tue Sep 11, 2018 4:28 pm

Add any type of text box or numeric control to the form. Linked field = AxB
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26733
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Calculation based on results of 2 other fields in form

Postby Maax555 » Wed Sep 12, 2018 12:08 pm

Villeroy wrote:Add any type of text box or numeric control to the form. Linked field = AxB

Yes, believe i tried this unsuccessfully. I added the field to a subform, changed subform to Query with content coming from the Q_LabourEst.
I then had the data field linked to the relevant result field in the query.
As is apparent I am no expert but believe this should work so probably have an issue somewhere else.
This is on the same form where i am trying to modify without creating a duplicate. I will concentrate on that one as i think I can get this working.
(thanks to your help).

thank you.
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
Maax555
 
Posts: 127
Joined: Tue Mar 28, 2017 11:56 am

Re: Calculation based on results of 2 other fields in form

Postby Maax555 » Wed Sep 12, 2018 12:13 pm

Ah ok, this is kind of working if i click in the actual calculation field and advance through the records it changes accordingly.
However the rest of the data on the form is not changing, which is to do with another issue I have.

thanks again.
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
Maax555
 
Posts: 127
Joined: Tue Mar 28, 2017 11:56 am


Return to Forms

Who is online

Users browsing this forum: No registered users and 0 guests