Update table for selection

Discuss the database features
Post Reply
dreamquartz
Posts: 881
Joined: Mon May 30, 2011 4:02 am

Update table for selection

Post by dreamquartz »

Hi All,

Trying to figure out the following:
When entering data in a form, I would like to have that data available for a new entry in that form.
I am trying to create a work around for the ComboBox for a different table.
I created a Form for entry of Person Info, like SurName and GivenName, and a ListBox and a TextBox on a SubForm for entry of a CityName.
I am able to enter the CityName in the TextBox and store it in the CityTable, but it does not show in the ListBox immediately.
I have to close the Form and open it again to have CityName available in the ListBox.

I would like to have CityName available in the Form without closing and opening the Form again.

I think it should be possible to create an Event, but I have no idea how, to solve this issue.

Can anyone guide me in the right direction.

Dream
LO 7.x, HSQLDB 2.7.x & Ubuntu 22.04 LTS.
User avatar
DACM
Volunteer
Posts: 1138
Joined: Tue Nov 03, 2009 7:24 am

Re: Update table for selection

Post by DACM »

dreamquartz wrote:I am able to enter the CityName in the TextBox and store it in the CityTable, but it does not show in the ListBox immediately...I have to close the Form and open it again to have CityName available in the ListBox.
Very nice design. I like how you think.

It is possible to trigger an update macro from an event, but have you tried adding a Push Button on the SubForm, setup to use the 'Properties > General (tab) > Action > Refresh form' option'? Otherwise, SubForm (List Box) update with a macro is practically boilerplate code so either search the forum, or we can post the code and event trigger for a Text Box (lose focus event).
AOO 4.1.x; LO 4.2.x; Windows 7/8 64-bit
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
dreamquartz
Posts: 881
Joined: Mon May 30, 2011 4:02 am

Re: Update table for selection

Post by dreamquartz »

The Refresh button does work.
It's not perfect, but a start.
A Push Button might be the way to go.
My problem at this point is, I have not a clue to program the button.
I will see what I can find.

Dream
LO 7.x, HSQLDB 2.7.x & Ubuntu 22.04 LTS.
User avatar
DACM
Volunteer
Posts: 1138
Joined: Tue Nov 03, 2009 7:24 am

Re: Update table for selection

Post by DACM »

dreamquartz wrote:The Refresh button does work.
It's not perfect, but a start.
Okay, that's what most people conclude when we steer them away from macros, and to the clunky built-in functions. But as built-in functions go, the 'Refresh form' button action is one of the more elegant. Just make sure the button is located on the SubForm (hidden form structure: image1 / image2) with the List Box for the most seamless function. Right-click the button and select 'Control...' to open the 'Properties' dialog box mentioned in my previous post above.
dreamquartz wrote:A Push Button might be the way to go.
My problem at this point is, I have not a clue to program the button.
But I'm not following this. A macro-driven Push Button won't do anything different in this case than a Push Button using the built-in 'Refresh form' action. You'll need to think bigger and better if you're willing to tackle macros. Like a macro that runs automatically as you leave the Text Box entry. Or a macro that allows you to double-click the List Box field to open another form to add content to the List Box, while refreshing the List Box upon closing the popup form. See also: Adding Entry into a list box.
...
AOO 4.1.x; LO 4.2.x; Windows 7/8 64-bit
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
dreamquartz
Posts: 881
Joined: Mon May 30, 2011 4:02 am

Re: Update table for selection

Post by dreamquartz »

I really would like to learn about macros, so I will check out what you suggested.
Maybe I am thinking to difficult, or maybe the answer lays in your suggestions.
I will let you know.

Update: I found what you meant by Push Button.
I did not know that you could simply select an "Action".
Now that I set it to Refresh Form, the Action leads to setting the Form to show the 1st Entry, while I would like it to show the Entry where there was a need to add a City.

Is there a way to set that as well?

Dream.
LO 7.x, HSQLDB 2.7.x & Ubuntu 22.04 LTS.
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Update table for selection

Post by RPG »

Hello

On the navigation toolbar and navigation control there is a button for refreshing a control. It is only active when the control can be refreshed.

Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
dreamquartz
Posts: 881
Joined: Mon May 30, 2011 4:02 am

Re: Update table for selection

Post by dreamquartz »

Hi Romke,

I am aware of that option, but I would like to program "Last Record (Ctrl+Alt+End)" as an Event, like "When losing focus", linked to the Push Botton, which I use to Refresh the Form.

Dream
LO 7.x, HSQLDB 2.7.x & Ubuntu 22.04 LTS.
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Update table for selection

Post by RPG »

Hello
dreamquartz wrote:I really would like to learn about macros,
Start with study the tutorials about macro programming. I like this
OpenOffice.org BASIC Programming Guide but other people like this Andrew Pitonyak's OpenOffice Macro Information. When you start with macros you need a detailed knowledge about your document and also of the API. When you start macro programming for forms you need also a detailed knowledge about SQL.

Here is a link to an example but you can find more example when you search for oListbox.Refresh.
http://user.services.openoffice.org/en/ ... sh#p212037
http://www.oooforum.org/forum/viewtopic ... ox+refresh
http://www.oooforum.org/forum/viewtopic ... ox+refresh


Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Post Reply