Open form on startup

Hi there,

I am quite new to LO. I am converting a big foto database from acces to LibreOffice.
I want to open a form on startup. In works op opening. I close the form, close the data base. Restart, Program gets stuck. Reopens, it works, etc etc

I use:
Dim oDataSource as Object
Dim oForm as Object
oDataSource = ThisDatabaseDocument.CurrentCOntroller
If Not (oDataSource.isConnected()) Then
oDataSource.connect()
End If
ThisDatabaseDocument.currentController.frame.ContainerWindow.IsMinimized = true
oForm=ThisDatabaseDocument.FormDocuments.getByName(“frmSwitchBoard”).open

What am i doing wrong?

test.odb (17.8 KB)
Schermafbeelding 2026-02-20 111322

To me here Google’s AI code is working.
Tested 3x close the form > close DB.

Option Explicit
Sub OpenForm
    ' Ensure connection is established
    Dim oController As Object
    oController = ThisDatabaseDocument.CurrentController
    If Not (oController.isConnected()) Then oController.connect()
    ' Open the specified form
    ThisDatabaseDocument.FormDocuments.getByName("Table1").open
End Sub

 
Checked it 10x:
test2.odb (17.7 KB)
 
Version: 24.2.7.2 (X86_64) / LibreOffice Community
Ubuntu package version: 4:24.2.7-0ubuntu0.24.04.4