Search code examples
libreofficelibreoffice-basiclibreoffice-base

How do I refresh all tables in a form? LibreOffice Base


I have 3 tables in a single form, they use SQL queries to select the data. I need to refresh them somehow, but nothing works.

E.g. this doesn't work at all:

oBaseContext = CreateUnoService("com.sun.star.sdb.DatabaseContext")
oDataSource = oBaseContext.getByName(dbName)
oCon = oDataSource.getConnection("", "")
oCon.getTables().refresh()

And this updates only the first table:

oDisp = createUnoService("com.sun.star.frame.DispatchHelper")
oFrame = ThisComponent.getCurrentController().getFrame()
oDisp.executeDispatch(oFrame, ".uno:Refresh", "", 0, Array())

How do I update them all?


Solution

  • Oh my god, it was so easy, I feel dumb now:

    Sub reloadAllTables
        Dim Forms : Forms = ThisComponent.DrawPage.Forms
        Dim i%
        For i = 0 To Forms.getCount()-1
            Forms.getByIndex(i).reload()
        Next
    End Sub