Database connection

Is it possible or advisable in LibreOffice to make the database connection accessible without having to request it each time it’s needed?

Similar to how a global variable works, it’s available regardless of the module that calls it. So, you connect once, and the connection remains available for any function or procedure that needs it?

Tools>Options>Base>Connections :question:

What is the purpose of a Connection without a Form and it’s
.ActiveConnection
or
[…].Connect()
?
Also: if you run a SP or Function – on Base GUI only possible in direct mode or Tools > SQL, of course – connection is available.

You’re right, ActiveConnection is tied to the active form and can’t become a global connection without causing problems.
.
However, I could have a database connection stored in a global variable that could be used to write or modify tables or other functions, as long as it’s not directly linked to the form, like an update related to a record. Is that correct?
.
The question that then arises is: is this really useful?
.
I was wondering about this and simply wanted to ask the question.

An update in Base can only be made

  1. directly in the GUI for Tables or Forms – and we have the connection of course;
  2. via Tools > SQL – and we also have the connection;
  3. via UPDATE command inside a script that one normally runs via button or some Event in a Form.

A “global” object Connection I think is stored when we create the .odb.

My concern was related to the use of connections within scripts. Some scripts use active connections because they involve updating tables related to the current record, but in other scripts, I sometimes simply need access to tables and certain data that don’t require active connections.
.
I realize I need to ask myself the following question: would the frequency with which this occurs in the scripts justify a database connection stored in a global variable?

I think que real question is: what you want to do with this data you need to access without a SELECT (be it a query proper or inside a SP or Function).
Or INSERT, UPDATE or DELETE via Tools > SQL or via script (“macros”).
Connection to another .odb?
Like linking Table(s) in MS Access?