Field C = Field A + Field B

I know this is a ridiculously basic question. I am new to LibreOffice Base with a bit of experience with MS Access…
I’d appreciate a quick help on this question.

I want to make Field C as the sum of Field A + Field B. Both Field A and B are numbers. That is it.
I guessed around some statements but none of them worked so far.

Thank you!

Hello,

Your question lacks some definition. It can mean multiple things.

It does appear you are talking about fields within a table. This is not a usual practice. You typically do not need to store the calculated result of other fields. If the figure is needed, it can always be calculated from the original figures by using SQL. This saves space in the record & database. Also, if the original figures change so must you update the calculated field. If you insist on doing this, you need to do so using an SQL Update statement. This is usually not done in the query section but rather from the main Base screen menu Tools->SQL.... The exact SQL needed depends upon the database you are using (not stated in question).

If you are talking about doing this on a form for display purposes, you can accomplish this with either a query in a sub form or by using a macro. With the query process the total would only be present on previously entered records while the macro could display the total immediately.

If this answers your question please tick the :heavy_check_mark: (upper left area of answer). It helps others to know there was an accepted answer.

HI, Thank you. I should clarify my situation. Say, a new transaction is entered, for example, $100 for Field A and $50 for Field B are input manually to a table via a form. I would like to automate $150 as the total amount and use it on form and other report. It does not have to be placed in Field C (next to Field A and B), nor in query. . As long as the total amt is stored somewhere in Base, I do not care how. . Any advice? How to do macro? Thanks.

@jbyuriko Don’t understand why you want this total amount stored at all. My answer explained why this is not necessary. Here are some links where my answers contain samples storing & NOT storing the total.

Base Form data uneditable

Adding 6 Fields for Total but some fields will have no Data to Add

I now understand that you do not need to have calculated data in the database. It can be pulled as long as you have the raw data in DB. Thank you.

If this answers your question please tick the :heavy_check_mark: (upper left area of answer). It helps others to know there was an accepted answer.

You need to use SQL as in Base only select queries are allowed, i.e. no data modification.
The SQL would be -


UPDATE "TableName" SET "FieldC" = "FieldA" + "FieldB"