Need help with LibreOffice .reload() command

Hello,

I’m hoping someone can help me resolve a problem reloading subforms in the “FilmsSeries” document form for this (partial) DB of LibreOffice Base.

Version: 25.2.4.3 (X86_64) / LibreOffice Community
Build ID: 33e196637044ead23f5c3226cde09b47731f7e27
OS: Windows 11 X86_64 (10.0 build 26100)

Tester.odb (538.3 KB)

Main form frm-FilmsSeries: TFilmsSeries table

  • Subform sfrm-Acteurs: query qsf_Acteurs
  • Subform sfrm-Actrices: query qsf_Actrices

Table control cntr-ActeursSelection of the sfrm-Acteurs subform:

  • Acteurs column (List Box): jIDactor table field from the JTActeursFS table, query ql_ActeursName
  • Year column (List Box): jIDactor table field from the JTActeursFS table, query ql_ActeursYear
  • Role column (List Box): jIDRole table field from the JTActeursFS table, query ql_Roles

Table control cntr-ActricesSelection of the sfrm-Actrices subform:

  • Actrices column (List Box): jIDActeur table field from the JTActricesFS table, query ql_ActricesName
  • Year column (List Box): jIDActrice table field from JTActricesFS table, query ql_ActricesYear
  • Role column (List Box): jIDRole table field from JTActricesFS table, query ql_Roles

The ReloadForm Basic procedure is executed at the end of the ‘ImportNames’ procedure. However, it doesn’t seem to be working properly. StarBasic’s .reload() command doesn’t seem to want to work completely.

Once the importation is complete, the form reloads and returns to the initial record. However, the subforms have been partially reloaded. Only the role appears, sometimes the year is set to 0, but still no actor or actress name. If I click the Acteurs or Actrices table control and click the Refresh button in the navigation bar once, the name appears; I click a second time and the year appears.

The only solution I have is to close the form and reopen it. At that point, everything is reloaded. This can be done within the macro, but it seems not to be the best approach. I don’t understand the behavior of LibreOffice and its .reload() command, which should, in principle, reload a form.

I’m submitting a ‘Tester’ Base file that might help one of you find a solution to my problem.

How the Tester Base file works:
1 - Open the FilmsSeries form
1 - Select a record from the Selection list
2 - Click the Import button (AsianWiki link)
3 - The Web page associated with the link will open and then the import form will opens.
4 - Complete one or more profiles to import and click the import button of the Importation form.
5 - View the result in the FilmsSeries form that is a partial reload.

Reload of a form with oForm.reload will only reload the data for the form. It won’t refresh the listboxes if there is new content for the listboxes. Might be this is a solution for you instead of reloading:

SUB FormReloadControlsRefresh
	DIM oDocument AS OBJECT, oDispatcher AS OBJECT
	DIM Array()
	oDocument = ThisComponent.CurrentController.Frame
	oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
	oDispatcher.executeDispatch(oDocument, ".uno:Refresh", "", 0, Array())
END SUB
2 Likes

RobertG,
.
I assume the procedure you’re sharing replaces the ‘ForceReloadSubForm oForm.getByName(gcSFActeurs)’ and ‘ForceReloadSubForm oForm.getByName(gcSFActrices)’ procedures of the ReloadForm procedure of my DB.
.
However, the ReloadForm procedure is executed from the “Importation_Noms” form, so the oDocument of the FormReloadControlsRefresh procedure will contain the ‘Frame’ of the ‘Importation_Noms’ form that has focus, rendering the following commands useless since the form to be reloaded is ‘FilmsSeries’.
.
After analyzing your procedure using the Witness window, I was able to see this: oDocument doesn’t contain the correct frame, so simply passing the name of the form to be reloaded as a parameter should work, and that solved the problem.
.
Although your procedure didn’t address the correct form, it contained the UNO service that resolved this issue. In fact, this API plays an equivalent role: closing the affected form and reopening it to properly reload the form and its subforms, regardless of the many SQL commands involved. This is something the .reload() command doesn’t seem to be able to handle.
.
However, I’d like to understand why the .reload() command can’t handle such a situation.
.
Anyway, Thank you, RobertG, your help is invaluable. This solved a major problem in my database management.

If you try to get a reload of the form by something like oForm.reload() it will only reload the content of the form, not the content of, for example, a listbox or a combobox. So you have to set

oForm.reload()
oListbox1.refresh()
oListbox2.refresh()
...
2 Likes

Side note: The reload command of the UI does include combo and list boxes.

@Villeroy : And this command is exactly what I use by the posted procedure.

OK, I see that list and combo boxes require special attention whenever a reload or refresh is involved. I would probably benefit from rereading the LibreOffice documentation.
.
As an amateur in this field, I’m not fully aware of all these subtleties; I’m learning them as I go along.
.
That’s why people like you, RobertG, Villeroy, and others, who have helped me are greatly appreciated. Thank you!