[Solved] Subform - Automatic update of displayed values?

Creating and using forms
Post Reply
Soprano
Posts: 11
Joined: Tue Mar 10, 2009 4:29 pm

[Solved] Subform - Automatic update of displayed values?

Post by Soprano »

 Edit: The right answer was b) (see my initial list below). That is, update happens only after saving which is an active user command. So I use a macro to achieve my goal. Thanks Villeroy for your replies! 
Dear all,

my first post, after search didn't give any results. Hope that I searched enough, don't wanna bother you with needless topics. Right, no endless prologues as well... :oops:

I'm trying to create a form with a subform, where the subform displays a record that is selected in the main form by a list control. Now whenever I change the value in the list control, I would expect OOo to update the display of the subform. But exactly that is not happening. Only when I navigate to another record of the main form and come back to the initial record, the changes are visible. Why?
  • a) a MacOS version issue? I've tried OOo 3.01 and NeoOffice 2.2.5 with the same result.
    b) my expectations are wrong - automatic update is not wanted in OOo (see the BookDealer example where the update of the buyer address requires a macro)
    c) I did something wrong (e.g. some form setting)
    d) a real OOo issue. The API reference says in its "Forms" chapter, see http://wiki.services.openoffice.org/wik ... /Sub_Forms last sentence:
    Every time the cursor in the master form moves, the detail form reloads after filling the salesman parameter with the actual value of the master forms SNR column.
    Therefore I would think that this is the intended behaviour.
Please help - what is the answer?
Thanks a lot!
Last edited by Soprano on Sat Mar 21, 2009 6:03 pm, edited 1 time in total.
OOo 3.0.X on Mac OSx Leopard
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Subform - Automatic update of displayed values?

Post by Villeroy »

Soprano wrote:Every time the cursor in the master form moves, the detail form reloads after filling the salesman parameter with the actual value of the master forms SNR column.
"Cursor" means "row-cursor". Every time the row-cursor in the master form moves, the detail form reloads ...
Subforms are used to get editable result sets for related items of the main form's selected record or you can use them to show calculated results related to the main form's selected record.
A database form to demonstrate a relation between form and calculated subform

You want one form filtered by an unbound combo/list/text box control, which is a total different thing and possibly is the single most frequently asked question about Base.
There are form-based filters together with control property "Filter Proposal" to let the user compose arbitrary complex filters.

Countless macros have been written to let a box apply a filter.
Search in http://www.oooforum.org/forum/search.phtml for all words "form filter macro" in the Base forum.

And then there is another approach where you bind the box to some table in order to let the database do the filtering by means of SQL.
[SOLVED] Form: enter a string expression to populate a grid (text box filtering a form by sub-strings)
my first quick&dirty drafts
Same with pictures and combo box (btw: do not use Base with many large pictures)
Another example filtering shops and shops' articles by sectors (many forms merged in one form document)
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
Soprano
Posts: 11
Joined: Tue Mar 10, 2009 4:29 pm

Re: Subform - Automatic update of displayed values?

Post by Soprano »

Thanks for the quick reply! Here's mine:
Villeroy wrote:You want one form filtered by an unbound combo/list/text box control
No, I want to establish the relation between the table in the main form and the one that is shown in the subform. For that, I would use the list box (based on a SQL query) to choose the sub-table's row related to the main table (e.g. choosing the salesman that made a sale when entering the sale; therefore, for example if I choose "Paul Smith" as the salesman, I would want to immediately show e.g. his address to be able to decide whether I chose the right salesman or even to modify his address in the same form if changed - well stupid example, my application is a little different and makes more sense. But for this reason, I would need immediate update of the subform. The makro within the BookDealer example, however, shows me a path to do it using a makro (although I wanted to avoid that). From that I understood (in the meantime) that reloading the subform requires to save the main form's record first.
However, your links are useful and I'll continue to learn from them. After that I'll come back to choose whether my issue is solved or ask further questions.
Thanks so far!
OOo 3.0.X on Mac OSx Leopard
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Subform - Automatic update of displayed values?

Post by Villeroy »

It works as you describe. When you select the record of 'Paul Smith' from the main form's table of persons you immediately see another record set's related entries in the subform. But when you select the name from a list/combo box then you write the control's bound value into some table as soon as you store the current record to disk which happens automatically when you move to another record.
Change the person in the main form, move to another record and back to the previously edited one and the subform reflects the changed person. When you put something into the form nothing is triggered at all unless you add your own form-triggers through macros.
As you can see in the examples I use refresh buttons to refresh a subform of a modified (and stored) main form.
 Edit: The subform is updated as soon as you store the parent form's edited record to disk. The displayed current record is not the current record until the content is actually stored in the database. Hit the save button on toolbar "Form Navigation". 
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