Autorefresh column

Discuss the database features
Post Reply
mihmih
Posts: 111
Joined: Wed Feb 18, 2015 9:21 pm

Autorefresh column

Post by mihmih »

Hi,

I have a table in the subform, I would like to click on this table (get focus) and make autorefresh the sql command in one of the columns (list box). How can i get it? Thanks for help.
LibreOffice 4.2 on Windows7
UnklDonald418
Volunteer
Posts: 1547
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Autorefresh column

Post by UnklDonald418 »

A table grid control on a subform does have an event When receiving focus, so a macro could be constructed using that event to locate the list box control, then one line of the macro, something like

Code: Select all

oControl.refresh 
would force the list box query to execute.
Without more detailed information on the form it would be difficult to give anything more specific.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
mihmih
Posts: 111
Joined: Wed Feb 18, 2015 9:21 pm

Re: Autorefresh column

Post by mihmih »

Thanks for the answer, I will try to explain it in more detail...

So I have four tables: with contractors, with orders from contractors, with the products of the contractors and a junction table (ID, order ID, product ID). The table with the products contains the contractor's ID.

And the problem is a form with adding orders ... in this form i adds order data in the main form (the source is a table of orders), then I go to the subform (table), where i adds product data (the source is a junction table). The first column in this table is the list box, where from the drop-down list I select products from the product table (the source of this drop-down list is the product table). All I want is that this list should be limited only to the contractor that was selected from the drop-down list in the mainform on this form, where i adds order data.
LibreOffice 4.2 on Windows7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Autorefresh column

Post by Villeroy »

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
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Autorefresh column

Post by Villeroy »

[Base, Python] Tiny Macro Refreshing Forms, List/Combo Boxes
together with viewtopic.php?f=100&t=94393 (cascading list boxes).

It would be easier if you could use a subform with a grid control instead of a list box.
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
mihmih
Posts: 111
Joined: Wed Feb 18, 2015 9:21 pm

Re: Autorefresh column

Post by mihmih »

Thanks for the answer, but I have looked through all the forms in both databases ("movies" and "countries_city") and I do not see a similar situation to that described by me...
LibreOffice 4.2 on Windows7
F3K Total
Volunteer
Posts: 1038
Joined: Fri Dec 16, 2011 8:20 pm

Re: Autorefresh column

Post by F3K Total »

Hello,
i tried to create a simple sample DB. If i got you right, products and orders depend on the contractor. I used a one-row-filter-table to store the contractors ID, then a linked-order-subform to display the contractor orders and finaly another linked subsubform to display/work on the junction tables content. The listbox in the products column of the table-control is filtered by contractors ID stored in the filter table.
Attachments
CONTRACTORS_ORDERS.odb
(18.43 KiB) Downloaded 164 times
  • MMove 1.0.6
  • Extension for easy, exact positioning of shapes, pictures, controls, frames ...
  • my current system
  • Windows 10 AOO, LOLinux Mint AOO, LO
mihmih
Posts: 111
Joined: Wed Feb 18, 2015 9:21 pm

Re: Autorefresh column

Post by mihmih »

it looks like that's what I meant. thanks a lot .... if it could be done without the "set contractor"-button it would be perfect :)
LibreOffice 4.2 on Windows7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Autorefresh column

Post by Villeroy »

Well this is just another trivial example of macro free "power filtering".

If you want to maculate this solution with a macro in order to save one click:
1) Install my AutoRefresh.py
2) Call the form navigator and move the "set contractor" button to the filtering parent form.
3) set its action from "Refresh" to "Save" and its default button property to Yes. Now it reacts on the enter key and saves the stored filter criterion in the filter table.
4) Add a hidden control to the filtering form. Name it AutoRefresh and set its value to F_ORDERS (name of the subform to be refreshed).
5) Assign macro My_Macros>pyDBA>AutoRefresh>form_Action to the filtering form's event "After record action". Now the macro will be triggered after the form has been saved and it will read the name of the subform to be refreshed from the hidden control. The same macro can refresh multiple forms, subforms, parent forms or any list boxes and comboboxes in all forms on the same form document.
Last edited by Villeroy on Mon Mar 11, 2019 4:19 pm, edited 1 time in total.
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
mihmih
Posts: 111
Joined: Wed Feb 18, 2015 9:21 pm

Re: Autorefresh column

Post by mihmih »

ok, I have a question, maybe a stupid question ...

For Python macros to work, python must be installed on my computer?
LibreOffice 4.2 on Windows7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Autorefresh column

Post by Villeroy »

It comes with your office.
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
Post Reply