Auto displaying form at startup - almost working

I used the code suggested here to make my database open a form at startup.

If I open LibreOffice Base then select a database to open the desired form auto starts correctly.

If I double click on the .odb file to open it I get “The connection to the data source could not be established”. How do I fix this? Perhaps I need a line of code to specify the db being opened is the one the form is in?

Take this at the first line in your procedure (after all variables are declared):

oDatasource = thisDatabaseDocument.CurrentController
IF NOT (oDatasource.isConnected()) THEN oDatasource.connect()

2 lines of code:

Sub onOpen_openForm()
ThisDatabaseDocument.CurrentController.connect()
ThisDatabaseDocument.FormDocuments.getByName("FormNew").open()
End Sub