I am trying to filter a sub-form grid control based on main form table selection.
If user does not select any rows on the main form , a macro gets all the rows displayed, and uses it to filter the sub form. If the user selects on or more rows, they are used as the sub form filter.
The macros do work, but when the filter is applied to the sub-form, selection of rows is lost in the main form table grid control.
This is how I retrieve the rows selected:
oForm = ThisComponent.Drawpage.Forms.getByName("MainForm")
oTable = oForm.getByName("MainForm_Grid")
oTableView = ThisComponent.getCurrentController().getControl(oTable)
oSelectedRows = oTableView.getSelection()
iStart = LBound(oSelectedRows)
iEnd = UBound(oSelectedRows)
filterIds = ""
For n = iStart to iEnd
oForm.absolute(oSelectedRows(n))
t = oForm.columns.filter_id.getInt()
filterIds = filterIds & t
next
Then I use the filterIds string to Apply a filter to the subform. I tried a few posts using oTableView.Select like this one but I was unsuccessfull getting error messages about illegal arguments and such.
Since I already retrieve the selection before applying the filter, I thought it would not be too hard to restore it…
Does anyone know how I can prevent this from happening, or restore the selection after the filter is applied ?