Boundfield property

Hello everyone,

Within the same form, I created a form with two table controls, each of them had one text box column within. One of them was bound to a table in a database, the other was left unconfigured.

I tried to programmatically configure the uninitialized column but it looks like the boundfield property is what I’m missing. The code, invoked by a push button in my case, is as follows:

dim oForm as object: oForm = oEvt.Source.Model.Parent
dim oTextBox as object: oTextBox = oForm.getByName(“Table Control 1”).getByName(“Text Box 1”)

oForm.commandType = com.sun.star.sdb.CommandType.COMMAND
oForm.command = “select * from database_table_name”
oTextBox.datafield = “database_column_name”
oForm.reload()

I’m reading in the documentation about the forms in Libreoffice developer’s guide, specifically about the Data Awareness aspect of it. But I’m not a professional programmer, and some of these conceptual aspects are still beyond my comprehension level.

As a matter of fact, an easy and pragmatic solution is to simply establish the initial configuration as the form is being built. At which point, the code above is able to provide the necessary service by switching in between table as needed. I just thought I’m going to ask to gain a bit more understanding of the UNO API.

I guess :thinking: this should be along this line.

oForm.command = "select * from ""database_table_name"""

Dim oTheColumn As Object
Dim aux As [data type of the record]
[…]
oTheColumn = oForm.Columns.getByIndex([index ]) ’ 0 based index
or getByName(“
These are the columns returned by the SELECT.
The Form’s recordsource.
 
aux = oTheColumn.getString() ’ or adequate data type
oTextBox.Text = aux
 
NOT TESTED