Insert Filter in Form Table in Libreoffice Base

Hello guys, (CORRECTING QUESTION) I actually want to filter the table according to the option selected in the list box. A Sample follows, in which if I select option 4 in the list box, only the records corresponding to C, D and F appear in the table. (REMEMBERING THAT THERE ARE OPTIONS IN THE REPEATING LISTING BOX). I can do this using the Form Filters option that Libreoffice Base itself offers, however, it takes considerable time to write the code in the field.

Database: Embedded HSQLDB

Operating system: Linux Mint

LibreOffice version: 7.0.3.1

SAMPLE: Amostra.odb

Hello,

A few items are not clear. Do you want to know how to fill the list box? There are multiple ways. What you posted looks more like a simple list than a query. Could be entries in a table and use that for the list box. Could be entered through the list box properties General Tab → List entries.

Is this also a question on how to filter a table? There are numerous examples of that posted on the Ask site. If specifically how to do it for your situation a sample is needed. If so, edit your question and add there. Please no personal or confidential information in the sample.

Hello Ratslinger, I actually want to filter the table according to the option selected in the list box. A Sample follows, in which if I select option 4 in the list box, only the records corresponding to C, D and F appear in the table. (REMEMBERING THAT THERE ARE OPTIONS IN THE REPEATING LISTING BOX). I can do this using the Form Filters option that Libreoffice Base itself offers, however, it takes considerable time to write the code in the field.

Hello,

While working on this, don’t comprehend what this means:

(REMEMBERING THAT THERE ARE OPTIONS IN THE REPEATING LISTING BOX)

It is because when selecting option 01 (A, B, C) from the list box, only records A, B, C, should appear in the table. When option 03 (A, B, D) is selected, records A and B must appear in the table (as in option 01) and also record D.
I don’t know if I managed to make it clear, but that’s it.

Hello,

Well it took a bit longer because I was trying to do this without using a macro. Unfortunately HSQLDB embedded is quite old and doesn’t have anything near what I was looking for. Maybe another database using an array in a field (such as PostgreSQL) but even there will require some more research and testing.

Instead went with a very short macro. Took your form and moved the list box to a separate internal form.

For the list box properties, on the General tab, the List Entries stayed the same. On the Data tab, the matching List content entries are the in portions of the SQL. Example:

( "Intervenções" IN ( 'A', 'B', 'C') )

Now when a item is selected in the list box, the Item status changed event is fired off and the macro moves the selected in statement from the list box to the filter of the form with the actual data table. The form is refreshed to display the selection and the form is cleared for when the form is opened on the next occasion.

Sample ------- Amostra.odb

Just a note, I can conceive of the list being in its own table and having the list box get the list from the table instead of the individual entries int the list box.

Fantastic! Thank you Ratslinger. I have to admit that Libreoffice Base is surprising me for the high level (taking into account that it is open source software) of its own tools and for the support provided in the forums.