Update subform grid when parsing records in a form grid in base

I’m trying to create a from in LibreOffice Base where a subgrid is automatically updated whilst parsing a main grid (i.e. pressing up and down arrows or clicking on a field).

The form has:

  • A grid with records from a tasks table.
  • A Subform with a grid with records from a subtasks table. Tasks and subtasks tables are linked 1-n via task-ID field.

I tried with a macro linked to the tasks grid that identified the selected rows. The problem is that many can be selected.
Then I tried with another macro that identifies which row is the current one (green arrow) and gets the value on the task-ID field. This part seems to work, but if I assign the macro to pressing a key it works for most of them, but not the arrow keys.

dim oColumnList as object
dim oGrid as object
dim theValue as variant
oGrid=oEvent.Source.Model
oColumnList = oGrid.getByName(“Task-ID”)
theValue = oColumnList.getCurrentValue()
Print theValue

Then I still have to make the connection with the subtask grid… and I wonder if I’m in the right path or if there is an easier way to do it.

Hello,

Tasks and subtasks tables are linked 1-n via task-ID field.

This appears to be a relationship you have set. This makes using the Wizard easier to create linked subforms but actually it s not required. Nor are macros. Just a common link of Master and Slave fields (properties of subform).

Information can be found in on-line documentation here → Data.

More within the LibreOffice documentation here → Documentation/Publications. See Base documentation Chapter 4 - Forms. Section on Main forms and subforms.

Absolutely perfect, I didn’t know links worked between grids as well, I had only done individual controls to subgrid, but now I see it is the relationship between form and subform that matters.