@Villeroy et all, sorry, sure. See below. All credits to @RobertG
Macro to be used in the ‘before record action’ of my form:
SUB IDSave(oEvent AS OBJECT)
stID = ""
oForm = oEvent.Source
IF oForm.supportsService("com.sun.star.form.component.DataForm") THEN
stID = oForm.getString(oForm.findColumn("ProjectID"))
loRow = oForm.getRow
END IF
END SUB
And in the ‘after record action’ of my form:
SUB IDGet(oEvent AS OBJECT)
oForm = oEvent.Source
oConnection = oForm.activeConnection()
oSQL_Statement = oConnection.createStatement()
IF stID = "" THEN
stSql = "CALL IDENTITY()"
oResult = oSQL_Statement.executeQuery(stSql)
WHILE oResult.next
stID = oResult.getString(1)
WEND
END IF
stSql = "UPDATE ""Project"" SET ""Saldo"" = CASE WHEN ""Bijgesteld Budget"" = 0 THEN ""Budget"" - ""Spent"" - ""Forecast"" ELSE ""Bijgesteld Budget"" - ""Spent"" - ""Forecast"" END WHERE ""ProjectID"" = '"+stID+"'"
oSQL_Statement.executeUpdate(stSql)
oForm.reload
IF loRow > 0 THEN
oForm.absolute(loRow)
ELSE
oForm.last
END IF
END SUB
And as ‘GLOBAL’ declaration (is that the right term) of variables within my ‘Main’ macro file:
GLOBAL stID AS STRING
GLOBAL loRow AS LONG
The above results both in calculating the 'Saldo" (= Balance), storing it in the ‘Saldo’ field of my ‘Project’ table when I save the record, as in showing me the updated ‘Saldo’ field on the screen (form) by returning to the new or changed record (row) of the ‘Project’ table.