On my Base Form I want to put a push-button to open another form within the same database. The name of the form to be opened is “ArticleStock”.
Is there a macro in Button-Properties-Event? I found one but it opens an external writer document.
You will nee a macro like this:
SUB OpenForm
ThisDatabaseDocument.FormDocuments.getByName("NameOfMyForm").open
END SUB
There is no event for Button to open another form inside a Base file.
Replaced ¨NameOFMyForm" with “ArticleStock”. Running the macro gives an Error
BASIC runtime error,
Type: com.sun.star.container.NoSuchElementException
Message: ArticleStock at ./dbaccess/source/core/dataaccess/defintioncontainer.css:403
Where is my error?
@Yumi : Show a screenshot of the main window of your database with forms pane. There should be a form named "ArticleStock".
Did you save the macro inside the Base file? All code I’m using together with Base will be inside Base file, not in “My Macros and Dialogs”.
I see 3 ArticleStock. Where does '3 ’ come from?
Good catch. Lets guess: The numbers for “ordering” the list of forms, so the actual Name is 3 ArticleStock and needs quoting.
Yes, my attempt to sort forms not in alphabetical order. And yes, the 3 has to be included in naming the form on the button. Thanks!
PowerFiltering_Switchboard.odb (452.0 KB)
Open the form named _SWITCHBOARD_
Notice the “Additional Info” property of each push button.
Notice the different macro calling the report.
What should be written in the buttons “Additional Info” field. I found no explanation in the Base Handbook or Forum.
Only one sentence from you “Paste the semicolon separated statements into the “additional info” box of the push button and assign the macro to the button’s execute event.”
Tried your database “PowerFiltering_Switchboard.odb” and clicking on a button results in the same error message. Maybe the problem is not with base?
Just have a look at the properties of my push buttons.
With my upload, I get another error message because I forgot to include “getParentObject” which is the name of a Basic function. You get an error about a form that can not be found by the name “Article Stock”. I replaced my uploaded database. Please try again.
Further explanation: I tried to write macro code that does not need any more editing. You call the same code – embedded in the database or in “My Macros” – from any push button on any form or subform attached to an embedded form. Just add the form’s (or report’s) hierarchical name, which may include folder(s), as additional info to the calling button. The macro finds the form’s embedding document and then the form (or report) to be opened, even if you organize forms and reports in folders.
Thank you! I followed the procedures in your database and it is working now without an error, opens the right form.
Saying this, I have not yet understood your macros, it will take some time to learn this…
Store the code under “My Macros” or within your document(s). Add push buttons, assign the buttons to the right routine (Open_Form_Button or Open_Report_Button) and add the hierarchical name to the additional info.
No need to understand nor edit the code.
NoSuchElementException ... Article Stock indicates that there is no such element named “Article Stock”. The error message is clear and you can rely on it being true. Does your actual form name include an additional space? Right-click>Rename… the form icon and inspect the text to be edited.

