Ask Your Question

Application.CurrentDb etc. throws error

asked 2016-11-20 07:49:46 +0100

owlbrudder gravatar image

updated 2016-11-20 09:16:19 +0100

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-<

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2016-11-20 15:45:15 +0100

Ratslinger gravatar image

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.



edit flag offensive delete link more

answered 2016-11-21 17:14:44 +0100

peterwt gravatar image

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.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-11-20 07:49:46 +0100

Seen: 116 times

Last updated: Nov 21 '16