Opening disclaimer: I’m just a novice on Libroffice Base and SQL, so please be kind to me
I have the table “Project” that contains a/o the following datafields:
- Budget
- Adjusted Budget
- Spent
- Forecast
- Balance
When saving a new record or a changed record I want the field Balance being updated.
I have created the following SQL that provides me with the desired result:
UPDATE “Project”
SET “Balance” =
CASE WHEN “Adjusted Budget” = 0 THEN “Budget” - “Spent” - “Forecast”
ELSE “Adjusted Budget” - “Spent” - “Forecast”
END
And I think that this translates to the following line in a Basic Macro:
sql = “UPDATE”“Project”“SET”“Saldo”" = ““CASE”” WHEN ““Bijgesteld Budget”” = ““0"” THEN ““Budget”” - ““Spent”” - ““Forecast”” ELSE ““Bijgesteld Budget”” - ““Spent”” - ““Forecast”” END”
However, I’m just not able to find a working method the have this SQL being executed when saving a new Project record or when saving changes to a record.
Please note that I am using a form to add/change/delete records to the table.
I’ve done a lot of searches in tutorials and on sites but haven’t been able to find the solution.
Can you please help me with that?