[Solved] Re: [libreoffice-users] Setting Base to open with a slected form

Hi :slight_smile:
Peter has let me know, off-list, that he solved the problem. Details are
sketchy (ie i didn't understand) but he's working on the Base Handbook at
the moment so this is a distraction.

Anyone who fancies their chances of being able to proof-read a chapter or 2
would be a huge help in getting the Base Handbook published more quickly.

Most chapters have been reviewed (tested for technical accuracy) already
and been kinda proof-read once but a final round of proof-reading would
help reassure those who have been involved with getting the guide/handbook
this far.

There are still a few chapters that need reviewing but it's tough work so
just proof-reading those already done would be great and could be done by
almost anyone.

Regards from
Tom :slight_smile:

Hey Tom,

It would be nice to post the solution here on the string that is
labelled "[Solved]" so that people searching for the solution can find
it. Maybe Peter should do that since he seems to have a better grip on
the solution.

The solution to getting LibreBase to open with a particular form involves several steps:
1. Create a macro
/Sub Menu_Main( )
Dim ObjTypeWhat
Dim ObjName As String
ObjTypeWhat = com.sun.star.sdb.application.DatabaseObject.FORM
ObjName = "MainMenuForm" 'The name of the form you want to open at Base start-up, this needs to exist.
If ThisDatabaseDocument.FormDocuments.hasbyname(ObjName) Then 'Check the form exists
ThisDataBaseDocument.CurrentController.Connect() 'If the form exists connect to the database
ThisDatabaseDocument.CurrentController.loadComponent(ObjTypeWhat, ObjName, FALSE) 'Open the form
Else
MsgBox "This is embarrassing, sorry, can't find the requested form to open!"+chr(10)+"Form Name = " & ObjName + chr(10)+"Check the details." , 48, "DS4A SBM encountered a problem!"
End if
End Sub/
2. Call the macro when the data base is opened:
From the top tool bar select: Tools>customise>opendocument
Add macro Main_menu to this selection.

When the data base is opened there is a delay of about 1 second before the form named in the macro opens.
This isn't quite as fast as Access, but in many other areas I found LibreBase to be more intuitive and than MS Access. I was able to convert my data bases from Access to LibreBase with all of the functionality the original Access databases, including reports, and in some cases with improved functionality.

Regards

Peter Goggin

The clean solution without macros:

1) Open an embedded form document and save it as a regular Writer document.
2) Close the form and load the new document from the new location.
3) Turn on edit mode, get the form design toolbar and click its 5th
button for the form navigator.
4) Get the main form's properties dialog, second tab "Data".
5) Copy the "Source" string first.
6) Unlike the embedded form, this one has a "Data Source" property.
Choose the registered name of your data source or use the [...] button
to pick the database file. (registration has several advantages).
7) The "Source" property is wiped out when you change the data source
but you have it in the clipboard. Paste it back into the "Source" box.
8) Repeat 5) to 7) for all the forms and subforms on the same form document.
9) Save and close the form document and make the file read-only.

Now you can open the form document just like any other document without
loading the database document and you can add ordinary hyperlinks to
switch between form documents. Of course, you can use desktop hyperlinks
too.
In rare cases you may use another option that is not availlable with
embedded forms: Subforms can be bound to data sources other than the
main form. For instance your subform may show all the database records
related to the main form's selected record that is stored in a spreadsheet.

Hi :slight_smile:
Thanks Andreas and Peter for saving my bacon there! Now we have 2 good
ways to do it :))
Thanks and regards from
Tom :slight_smile: