I found a very good example of opening and closing forms from LibreOffice Media_with_Macros.
The code is here:
REM This module iis for opening a form from another form.
REM At the same time the form, where the button is pressed, would be closed.
REM Will you get back from a form to one mainform (for naviagtion), you have only to start
REM ThisDatabaseDocument.FormDocuments.getByName( “Mainform” ).open
REM from the form in menue Tools → Customize → Events → Document is going to be closedSUB ToFormFromForm(oEvent AS OBJECT)
DIM stTag AS STRING
stTag = oEvent.Source.Model.Tag 'Input of the tag in “Additional information” of the control
aForms() = Split(stTag, “,”) 'First is written the name for the new form, followed by the old form
ThisDatabaseDocument.FormDocuments.getByName( Trim(aForms(0)) ).open
ThisDatabaseDocument.FormDocuments.getByName( Trim(aForms(1)) ).close
END SUBSUB ToFormFromFormWithFolder(oEvent AS OBJECT)
REM Form, that should be opened, ist the first
REM Is the form in a separate folder, this folder is defined with “/”.
REM So the subfolder could be found
DIM stTag AS STRING
stTag = oEvent.Source.Model.Tag 'Input of the tag in “Additional information” of the control
aForms() = Split(stTag, “,”) 'First is written the name for the new form, followed by the old form
aForms1() = Split(aForms(0),"/")
aForms2() = Split(aForms(1),"/")
IF UBound(aForms1()) = 0 THEN
ThisDatabaseDocument.FormDocuments.getByName( Trim(aForms1(0)) ).open
ELSE
ThisDatabaseDocument.FormDocuments.getByName( Trim(aForms1(0)) ).getByName( Trim(aForms1(1)) ).open
END IF
IF UBound(aForms2()) = 0 THEN
ThisDatabaseDocument.FormDocuments.getByName( Trim(aForms2(0)) ).close
ELSE
ThisDatabaseDocument.FormDocuments.getByName( Trim(aForms2(0)) ).getByName( Trim(aForms2(1)) ).close
END IF
END SUBSUB MainformOpen
ThisDatabaseDocument.FormDocuments.getByName( “Frm_VRT” ).open
END SUB
Now when I open another form (i.e. form0), the main form (i.e. form1) automatically closes at the same time.
What I want is when I open form0, form1 will not closes, and when I close form0, form1 get automatic refreshed (reloaded). I need help to achive this.
I attached an example odb file.
Thank you very much in advance.
I use Mac OS, LibreOffice 7.1.5.2, HSQLDB embedded.
Base_Print_Report_Example.odb (60.3 KB)