Can a LibreOffice .odb file automatically launch a form, immediately when opened?

Again with my “Charities” database project. When I open the .odb file, it simply brings up the usual database window, with the “Forms” tab active. Is there a way for it to also automatically open the master form for the database?

@hbquikcomjamesl
.
I don’t know if this can help you, but here is what I use to open a form when opening my database .odb file.
.
Basic Macro:

Sub OpenMainForm
     Dim oForm As Object
     ThisDatabaseDocument.CurrentController.connect("","")
     oForm = ThisDatabaseDocument.FormDocuments.getByName("Name of the form").open
End Sub

.
This procedure must be called from an event in the .odb file. To do this, select “Personalize…” from the “Tools” menu of your .odb file; in the “Events” tab, select “Open Document” and assign the Macro that you copied into a Basic module of your DB. Save and restart your DB.

1 Like

BINGIE! :grinning: :bangbang:

In my LibreOffice, it’s Tools/Customize, not Tools/Personalize. And I’ve just confirmed that you don’t need to declare oForm as a variable, or make the “open” call an assignment, unless you’re going to use the value elsewhere. The important part for simply getting the form up is:

ThisDatabaseDocument.CurrentController.connect("","")
ThisDatabaseDocument.FormDocuments.getByName("Name of the form").open

Glad it works.
.
I use LibreOffice French version. I made a literal translation of the Tools menu item. In French, we say: Personnaliser…
.
You are right, the oForm variable is useless.

Hello, could you detail the step-by-step explanation?
because my form is called “proffer” I would like which opens direction
how do we do?

Sub OpenMainForm
ThisDatabaseDocument.CurrentController.connect("","")
ThisDatabaseDocument.FormDocuments.getByName(“proffer”).open
End Sub

@tedjiel

I hope it will be clear to you, here it is:
.
1 - The “Sub OpenMainForm” procedure must be inserted in the Basic module of your choice in the “Standard” library (generally the one used) of your database.

To access macros: Tools → Macros → Edit Macros
.
2 - Customize the opening of your database document by assigning this macro from the Tools menu of your database (the window used to create your tables, forms and others).

To make the assignment:
a) Tools Menu → Customize
b) In the Personalize window select the “Open document” event from the “Events” tab
c) Click the “Macros” button
d) In the macro selection window, access the Basic module containing your macro, select and click OK.

When opening your DB, your form should open automatically.

Without any macro, you can store embedded form documents as stand-alone Writer documents, so you only need to open the Base document for maintanance or for the reports. Stand alone form documents can be opened by means of ordinary hyperlinks or desktop links. They are just Writer documents.

Open a form, call menu:SaveAs… and store it whereever you want. Repeat this for all the forms you need on a daily basis. Open the extracted form document and turn on design mode.
Get the (sub-)form’s property window and perform the followng steps for each form and subform:

  1. Copy the source name or SQL statement. Notice the source type (table, query or sql).
  2. If the database is registered, enter the database name. If not, cick the […] button and browse to the database document. This assignment of a database makes the source name disappear, which why it is a good idea to copy it first.
  3. Set the source type as before (table, query or sql) and paste the source name.

Once you reconnected all the (sub-)forms of a form document, turn off design mode and test the form.
Now make it open in read-only mode like the embedded form documents. menu:File>Properties… tab:Security. Check “Open file read-only”. You may also use your file explorer and revoke write access from the document file.

1 Like

I saved my forms, database works in each form but there is an error when I press the push button in the form
“”
A script structure error occurred while executing the script 'vnd.sun.star.script:Standard.Module1.New_profil?language=Basic&location=document on Basic.

Message : The following Basic script could not be found:
library: ‘Standard’
module: ‘Module1’
method: ‘New_profil’
rental: ‘document’
“”

the macro
Sub New_profil
const FormulaireAOuvrir =“New_profil”
Lien=ThisDataBaseDocument.FormDocuments.getbyname(FormAOpen).open

I installed your extension but when I restart, it opens the window of my PC folder, I don’t understand.

my first forum that I want to launch ''it’s a document with buttons that go to the other forms.

it can’t find .obd. ( This tool works with database documents (*.odb) only.)

how to put it in your macro for which opens when launching libreoffice base

Call Tools>Customize>Events and remove all entries trying to call a macro that does not exist and that is not needed anymore.

1 Like

ça fonctionne :slight_smile:

Launch a form on base startup