Listbox Updating 2 fields, possible?

Creating and using forms
Post Reply
Maax555
Posts: 127
Joined: Tue Mar 28, 2017 11:56 am

Listbox Updating 2 fields, possible?

Post by Maax555 »

Hi, I have a form with with a listbox to enter a status. The listbox updates the statusID correctly and details are saved as they should be.
However i also would like the StatusDesc updating at the same time so the user has a better idea of which status to choose.
I have a table which only has StatusID, StatusName and StatusDesc.
Is it possible for the StatusName listbox to bring in the StatusDesc at the same time?

many thanks
Last edited by Maax555 on Tue Jun 05, 2018 3:25 pm, edited 2 times in total.
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Listbox Updating 2 fields, possible?

Post by UnklDonald418 »

For your list box query try something like

Code: Select all

SELECT "StatusName" || ' - ' || "StatusDesc", "StatusID" FROM "YourTable"
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
Maax555
Posts: 127
Joined: Tue Mar 28, 2017 11:56 am

Re: Listbox Updating 2 fields, possible?

Post by Maax555 »

thanks UNK, however i was wanting the description to appear in a separate field so i could place this anywhere on the form.
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
Maax555
Posts: 127
Joined: Tue Mar 28, 2017 11:56 am

[SOLVED} Listbox Updating 2 fields, possible?

Post by Maax555 »

I have managed to solve this myself thanks to previous advice on subforms and a macro to refresh.
I moved the StatusDesc to a subform, linked the subform StatusID and added a macro to refresh the form as soon as the listbox was updated.
A very simple process but only able to do this as a result of the great help received on these forums.
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
Maax555
Posts: 127
Joined: Tue Mar 28, 2017 11:56 am

Re: Listbox Updating 2 fields, possible?

Post by Maax555 »

Spoke too soon. The refresh is refreshing the main form. As soon as i update the listbox the refresh takes the form back to a previous record.
I need to work out a macro to only refresh the RefreshSubform I think?

:-(
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Listbox Updating 2 fields, possible?

Post by Villeroy »

You can refresh the subform on the navigation toolbar when some subform element has the focus.
When a list box or combo box is foussed, you can use the second refresh button to refresh the list of the selected element.
Instead of the navigation toolbar, you can attach a navigation control to the subform. Use the form navigator to make sure that it belongs to the right subform.
Instead of any of these toolbars, you can attach a push button with action "Refresh form".
It might be possible to create a refresh button for a list/combo box by using an URL button with the right dispatch URL.

Dozends of refresh macros have been written over the years.
This is my version of a universal refresh macro triggered by a form event: viewtopic.php?f=21&t=88831 to refresh any (group of) forms/combos/lists after the current record has been removed/updated/inserted
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
Maax555
Posts: 127
Joined: Tue Mar 28, 2017 11:56 am

Re: Listbox Updating 2 fields, possible?

Post by Maax555 »

many thanks, i will have to study this carefully in all honesty its a little beyond me. It is a macro I prefer as I have avoided manual refreshing thus far.
I will for now add a manual push button to refresh so i can keep moving forward with my current form i am working on.

thanks
Regards Maax
LibreOffice 6.1.4.2 on Windows 7
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Listbox Updating 2 fields, possible?

Post by Villeroy »

Villeroy wrote:It might be possible to create a refresh button for a list/combo box by using an URL button with the right dispatch URL.
Push button properties:
1) Take focus on click = No since we want to refresh the focussed list/combo
2) Action = "Open Document or URL"
3) URL = .uno:RefreshFormControl
this is the dispatch URL behind the second refresh button on the navi toolbar.

Refreshing a subform does not require any such trick because there is action "Refresh form"
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