Reload a form completely using a macro

Testdb.odb (187.0 KB)
I have a form in base that uses multiple display elements. It is refreshed / reloaded using a button that is part of the form structure. Works fine for the table and the subforms with text fields displaying some SQL results that are part of that form.
Now I am trying to reload this form using a macro instead of asking the user to press the button.
When I reload the form element that contains the table, the subform and the textfields using a macro only part of the form (the table) is updated, the textfields do not update. Is there a way to reload the form completely, or do I need to address the reload of all the components in the macro?
Or is there a way to “press” the button using the macro?
Attached is the database file: Open “Einzahlungen” and find the drop-down below “Übersicht”, select “n1, v1” and see the table change. Now press “Laden” and see the textfields change. Check the form navigator and the macro for details. (Sorry for german labels and comments)

[Base, Python] Tiny Macro Refreshing Forms, List/Combo Boxes (View topic) • Apache OpenOffice Community Forum refreshes subforms, parent forms, list boxes and combo boxes automatically when the calling form content has been changed (new, deleted, edited record). To be set up by a hidden field.

Thank you Villeroy pointing me to a solution that is a kind of “form stored list of items to be updated”, nice solution. The list could be macro based also, having it inside the form is of course advantageous, it allows for more generic macros.
However, it needs updating the list every time an item is added or deleted (or the name changed).
More elegant would be to use the “reload form” that is available (e.g. when using the manual button). I would like to understand how I can trigger this / use this. (I will keep the button present anyhow to keep the form operational for those that deactivate the macro execution)

Reload the entire containing form document?
menu:File>Reload
or with a push button:
Action = “Open document or URL”
URL = .uno:reload
This is a special URL dispatching the same command as menu:File>Reload

Trying to reload a main form within a document, including all the subforms.
Works perfect with a “reload” button placed within the main form hierarchy.
BUT: object.reload() applied to the main form loads only some of the content of this main form.
Therefore I am looking for the correct method for the macro that reloads the main form completely.
I am pretty sure that it exists (as the button uses it internally), but I don’t know where and how to. Tried the API docs but this points to “reload” only as far as I can see.
Other (simple) alternative would be to “trigger” an “act as if pressed” method of the button. Again, I have no idea how this could be achieved as I didn’t find the correct place in the API docs.
Or should I consider the difference in behaviour as a bug? Thanks again for pointing me to some nice workarounds.

There are 2 “main forms” attached to your form document.
One is “MainForm” with subform “AnzeigeTafel”, the second independet main form is “Eingabemaske”. It does not refresh automatically because it is not linked to any parent.
Do your really believe that macros do anything good to your simple database? Macros are pure waste of time. You did not even start to explore this hell of an API where Base forms is one of the worsts parts. Since many years I run intermediate complex databases with Base frontends with no macro other than the one I’ve linked and a second one. Both saves some clicks on forms that would be fully functional without any macro.

Hi Villeroy,
I tried to set up the whole UI of the Database without any macros. Users complained about the need to do press the “refresh” every time they changed the selection. So I decided to add a small simple little macro that triggers the refresh every time the selection is done to ease the use and create a better user experience.
The sample is a (reduced) copy of one of the forms the users use, together with an absolute minimum of tablets and data to show the problem.
Of course I am able to do a workaround (the refresh button is already a kind of workaround), but I would like to keep any code I add as simple and straight forward as possible to be able to maintain it in the future (the UI is not really the main concern of the application I am working on).
As I failed trying to identify the correct method that does what the button does I first searched for comments / requests that might answer my question, and finally did the test database and posted my question.
However it seems the solution is to label it a bug, no-one could point me to the correct method and go into workarounds (of course not linking this).

Hello,

The problem is in your macro. You commit the data but do not update the record. After this line:

oAusgabeAuswahl.Commit

add this line:

oAusgabeAuswahl.Parent.updateRow()

So you ask then why the button works? When you click the button you change from the main form to the sub form and that commits and saves the record.

1 Like