libreoffice base how to filter a table in a form using a combobox ..other

Hi to all … I’m learning libreoffice basic … library Access2Basic …
Someone can tell me a good tutorial to learn the event driven language libreoffice basic ?

I’ m tryng to filter a record from a table in a form … in this form there is a combobox … the combo list is filled with a field in the table using a sql query… when changes the text in the combo … it updates the table and refills the form … it works! using a macro (Sub) on the combo event “on text changed”.
The form is used also to add new records in the table using the bottons under the form(new record and save record)… a field in the table fills the combobox list…
How can I update the combo list after I added a new record into the table ?
I’m thinking to use the Requery method of the combox (combo.Requery) on a event … but on what Event ?
Where can I find events triggered on table or database update ?
Thank You in Advance!

Hi Ratslinger this is the small odb file … MioDatabase.odb

Hello,

In regard to Star Basic (don’t know of actual tutorials) see these posts:

https://forum.openoffice.org/en/forum/viewtopic.php?f=45&t=90283

As for the actual question, not certain why you are using a combo box. Most often this situation uses a list box.

As for the code, you can simply obtain the control and refresh it:

oDrawPage = ThisComponent.getDrawPage()
oForms = oDrawPage.getForms()
oObj1 = oForms.getByName("YOUR_INTERNAL_FORM")
oObj2 = oObj1.getByName("YOUR_CONTROL")
oObj2.refresh()

Now for the event, on the form (or sub form) where entering the record, use:

After record change

Use the Form Navigator to get to the form/sub form events.

Edit 2020-05-23:

Using the table filtering (link in comment) have eliminated the need for all your macros except to refresh the combo box. This is now done with the combo box attached to the filter table and a refresh button to get the desired selection. New entries in the record will reflect in the combo box because of the macro in this answer.

Sample ---- Filtering.odb

Ratslinger thank you for your help! I followed your suggestment so I 've assigned your macro on the event After record change into the event list into the form properties … is it all right ? But the problem is the same ,… when I press the save record button in navigator the combo list doesn’t refresh :frowning: … it refresh only when after I change the combo value !
it should be in order … 1) update the record, 2) update the data source (the table) , 3) update the combo list from the table changed …
(I prefer the combo because I can pick the item using mouse pointer or using keyboard)
How can I send you my small odb file for your correction ?
Thank You in advance !

Hello,

You can use mouse or keyboard for list box also.

You can edit your question (lower right of question) and use the toolbar (upper left of question) paperclip icon. Click on that and then select and post your sample. No personal or confidential information please.

Hi Ratslinger , I’ve uploaded my small odb file in footer of my question … it’s structure is very simple … 1 table and 1 form … This is only a small utility, a small phone book for writing and searching for phone numbers in a italian hospital , search for ward name… no personal or confidential information … data records in table are simple fantasy text … Sorry for my language … I’m italian so english language isn’t my language! Thank you again for your help !!!

@schiame,

See some issues with your sample. Will be attaching a sample later. For now you may want to look at this post → Filter/Search with Forms (leveraging SubForms).

@schiame,

Please see edited answer