[Solved] Refresh form action does not refresh listbox

Discuss the database features
Post Reply
grfilho
Posts: 11
Joined: Thu Jun 12, 2008 3:39 pm

[Solved] Refresh form action does not refresh listbox

Post by grfilho »

Hi, I hope someone can help me out with a question. I hope I can spell it out in a way that makes sense ;)

I have a form linked to a table (Table1) with a Listbox control linked to a query (Query1). The query (Query1) extracts data from another table (Table2). Table1 and Table2 have a one-to-many relationship. When opening the form, the Listbox loads correctly the output of the query (Query1). No problem here.

I also have a refresh button linked to the refresh form action in the main form.

If I keep the form open and update the contents of Table2, the Listbox is not updated to reflect the new information. Not even if I click the refresh button. The contents of the Listbox are only updated if I close and reopen the form. Question is how do I make changes in Table2 reflect in the Listbox control without having to reopen the form and preferably without macros?

To illustrate what I mean do the following:
1. Open the attached database
2. Open the Form1 form
3. Check the contents of the listbox (click the arrow on the right)
4. Change field1 or field2 in the table subform (or change field1 or field2 directly in Table2) keeping Form1 open
5. Save changes
6. Click the Refresh button in Form1
7. Check the contents of the listbox again (click the arrow on the right)

Even though the table fields were updated (you can see this in the table subform) the Listbox contents is not updated.

Any help is appreciated.
Attachments
refrsh_test.odb
(22.72 KiB) Downloaded 585 times
Last edited by grfilho on Fri Aug 01, 2008 9:20 pm, edited 1 time in total.
OOo 2.4.X on MS Windows Vista + MS Windows XP SP2
User avatar
Villeroy
Volunteer
Posts: 31365
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Refresh form action does not refresh listbox linked to query

Post by Villeroy »

First you need to store the changed record to disk through a button on the main form before you can refresh the calculated subform.
'nother example: http://user.services.openoffice.org/en/ ... hp?id=1266
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
grfilho
Posts: 11
Joined: Thu Jun 12, 2008 3:39 pm

Re: Refresh form action does not refresh listbox linked to query

Post by grfilho »

Thank you for your reply. I believe your reply does not apply to my problem.

I know I have to commit the changes to disk before refreshing the form and I did that.

Some things about the example I uploaded:
- I saved the updated record directly in the table and keeping the form open, not through a button but I believe the effect is the same. Changes are commited to disk. Please, try it in the uploaded file
- The Listbox is not in a subform. It is in the main form. The refresh button acts in the main form too.

Apparently the refresh form action is not refreshing Listboxes linked to queries.

Any other suggestions?
OOo 2.4.X on MS Windows Vista + MS Windows XP SP2
grfilho
Posts: 11
Joined: Thu Jun 12, 2008 3:39 pm

Re: Refresh form action does not refresh listbox linked to query

Post by grfilho »

See the screenshot for what I mean.

The subform table (Table2) has the changes commited (saved) for field1. The listbox is a concatenation of field1 and field2 from Table2 through a query (Query1) and even if I refresh the main form (where the Listbox is located) the Listbox is not updated. The mainform is linked to Table1 and the subform to Table2.
Attachments
Base_bug.PNG
OOo 2.4.X on MS Windows Vista + MS Windows XP SP2
grfilho
Posts: 11
Joined: Thu Jun 12, 2008 3:39 pm

Re: Refresh form action does not refresh listbox linked to query

Post by grfilho »

I tried the very same thing in MS Access and it seems to work there. I created exactly the same setup I created in Base. In MS Access the listbox is refreshed at the time I save/update data in Table2. I don't even have to refresh the form.
The problem only happens in Base and if the Listbox is linked to a query that is linked to a table that is not the table in the main form. Oddly enough the subform updates ok but not the Listbox in the main form.

Anyone has any ideas why this happens and how to solve it? Is this a Oo Base known bug?

Thanks again for taking a look into this. ;)
OOo 2.4.X on MS Windows Vista + MS Windows XP SP2
User avatar
Villeroy
Volunteer
Posts: 31365
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Refresh form action does not refresh listbox linked to query

Post by Villeroy »

Base is the drunken cousin of the OpenOffice.org components. If you are very proficient with databases and scripting you may be able to build something useful within days what can be done in Access within hours. http://user.services.openoffice.org/en/ ... 426#p39426
May be you can solve this without macros with some combination of form, subform and refresh-button. May be you need a macro. You can find macros to refresh list controls in this forum or at oooforum.org to solve this problem for your particular case.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
grfilho
Posts: 11
Joined: Thu Jun 12, 2008 3:39 pm

Re: Refresh form action does not refresh listbox linked to query

Post by grfilho »

I see what you mean Villeroy. I would use Access, however I do not have a license at home (only at work) so my hands are a bit tied. It is a shame that Base is still very limited and buggy, but hopefully this will get better in the future.

Anyway, I checked your suggestions and I was able to implement a control refresh with a macro. It is not the best solution but it will do for now. If anyone is interested I implemented the following code in a macro and called it from the listbox when the listbox receives focus:

Code: Select all

Sub Macro_Refresh (oEv as object)

      oEv.source.model.Refresh

rem ... this will refresh the list of a listbox if the table has changed which supplies the list

End sub
Thanks for the help.
OOo 2.4.X on MS Windows Vista + MS Windows XP SP2
User avatar
Villeroy
Volunteer
Posts: 31365
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved]Refresh form action does not refresh listbox

Post by Villeroy »

I'm glad you found your way. Unfortunately, Base is so limited that you reach the point of scripting quite soon.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
arnotixe
Posts: 1
Joined: Fri Nov 23, 2012 7:15 pm

Re: [Solved] Refresh form action does not refresh listbox

Post by arnotixe »

Cool this solution helps :bravo:

Next for me is to find out how to update all controls in the form :D
LOdev Libreoffice Version 3.6.1.2 (Build ID: e29a214) on linux mint
Post Reply