Application.CurrentDb etc. throws error

I am getting to grips with Libre Basic via the helpful link text

In that page it clearly states one can refer to the current database as either Application.CurrentDb, or just CurrentDb. Equally, the forms collection can be referenced as 'Forms(“formname”) and the other collections should work the same way.

Clearly I am doing something wrong, because when I write a macro including that statement, I get an error.

Sub subTest
    Dim odbTimbercraft As Object
    Set odbTimbercraft = CurrentDb
End Sub

The ‘Set’ statement throws this error: “Basic runtime error - Object variable not set”

What am I doing wrong?

Any help would be appreciated.

Later …

I have since found a partial clue. In form frmOrders I have attached this macro to a button:

Sub subTest2
    Dim frmMyForm as Object
    Set frmMyForm = getObject(Forms!frmOrders)
End Sub

When I click the button, the code still throws an error at the Set statement, but it is more helpful: “BASIC runtime error. Property or method not found: frmOrders”. As it is being invoked from frmOrders, I am puzzled as to what is going on.

I am sure I am looking at an incorrect or out-of-date object model for Base, but don’t know where to look for further information. "8-<

Hello. The link you provided is the option to use the included library for Access2Base. This allows similar use of the coding in MS Access. If this is what you want, you have missed an important step in starting. You must first load a library as shown on this page - click here.

If however you want to learn the standard basic coding used in Base and other LO products, then you should follow some of the documentation found here - TDF. Under the Libre Base section there is “Chapter 9 - Macros”. It provides many examples.

To help get you started I have attached two working samples - one using Access2Base and the other using regular basic.

SampleAccess2Base.odb

LOBaseMacros.odb

I am attaching a sample database showing how to open a Form or a Table using LO Basic without using the Access2Base Library.
BasicSample.odb

Opening a Form is very easy.