Hello,
Certainly not too familiar with Access2Base. Tried it when switching from Access a few years ago. Decided to learn UNO API instead. Revisiting this I am glad at the direction taken.
With a bit of testing, got the code to work by using the Base form name and not the internal form name. Personally don’t understand this. Not certain how this would work if you had multiple internal forms as I use this quite often. Also, your OpenForm statement is to actually open a Base form and not to gain access to the existing form. Not certain that is what you actually wanted. Tested with code similar to yours (different names):
Dim ofForm as object
Dim ocControl As Object
set ofForm = Forms("USE_EXTERNAL_FORM_NAME")
ocControl = ofForm.Controls("txtLeif")
MsgBox ocControl.Value
Also as a test out of curiosity, tested with the control on a subform:
Dim ocDate As Object, vValue As Variant, sText As String
Dim ocSubform As Object, osfSubform As Object
Set ocSubform = Controls("USE_EXTERNAL_FORM_NAME", "USE_INTERNAL_SUBFORM_NAME")
Set osfSubform = ocSubform.Form
ocDate = osfSubform.Controls("myDateField")
sText = ocDate.Text
vValue = ocDate.Value
MsgBox sText & " - " & Day(vValue) & "/" & Month(vValue) & "/" & Year(vValue)
May try another time to investigate how to utilize multiple internal forms.
Edit 2019-10-02:
It is possible with Access2Base you are not loading the library and setting the connection:
If GlobalScope.BasicLibraries.hasByName("Access2Base") then
GlobalScope.BasicLibraries.loadLibrary("Access2Base")
End If
Call Application.OpenConnection(ThisDatabaseDocument)
A routine of this type can be set when opening the document.
However, attached is a sample of macros using both Access2Base and Star Basic to display the contents of a text box. The single form has buttons to accomplish this.
Edit #2:
Modified sample to separate the loading and connection macro and added the closing connection macro. These were added to the .odb events under Tools->Customize
on the Events tab:
Sample------- AccessVsBasic.odb