Page 1 of 1

Listbox Updating 2 fields, possible?

Posted: Mon Jun 04, 2018 5:34 pm
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

Re: Listbox Updating 2 fields, possible?

Posted: Mon Jun 04, 2018 6:41 pm
by UnklDonald418
For your list box query try something like

Code: Select all

SELECT "StatusName" || ' - ' || "StatusDesc", "StatusID" FROM "YourTable"

Re: Listbox Updating 2 fields, possible?

Posted: Tue Jun 05, 2018 9:43 am
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.

[SOLVED} Listbox Updating 2 fields, possible?

Posted: Tue Jun 05, 2018 9:56 am
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.

Re: Listbox Updating 2 fields, possible?

Posted: Tue Jun 05, 2018 3:27 pm
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?

:-(

Re: Listbox Updating 2 fields, possible?

Posted: Tue Jun 05, 2018 3:54 pm
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

Re: Listbox Updating 2 fields, possible?

Posted: Tue Jun 05, 2018 4:49 pm
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

Re: Listbox Updating 2 fields, possible?

Posted: Tue Jun 05, 2018 8:44 pm
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"