Basic: How to set the text displayed in a combo box?

How can I set the text showing in a form’s combo box (like when record motion occurs)?

(I’m not seeking to set to the underlying list of choices in the combo-box, rather the text showing before clicking, or between text box usage.)

Here’s what I’ve learned so far:

oEvent.Source.Text = "some text"

Will set the current combo box text from an event from this, and only this, Combo Box.

But I can’t seem to find a similar method for any other combo box, e.g. one named “Foo”. In other words, and in particular,

oEvent.Source.Model.Parent.getByName("Foo").Text

is missing Text, (i.e. it does not seem to have a setText method).

Also I can’t seem to locate a setText method when starting from thisComponent as follows:

thisComponent.getDrawPage().Forms.getByName("MyForm").getByName("Foo")

I want to be able to show the current record’s values in several different combo boxes used to lookup the current record in this form where you can use the combo boxes to select records.

thisComponent.getCurrentController().getControl(oEvent.Source.getByName("target control name")).Text = "some text"

@EasyTrieve .Text applied to a Combo Box is a Property and not a Method and is read/write. If a Combo Box is the source of an event then -


Text$ = oEvent.Source.Text         'Text$ is the text of the selected list item
oEvent.Source.Text = "some text"   'set the text to display in the Combo

My interpretation of your post is that you want to - select a record using any of the Combo Boxes and set the Form to display that record (which your uploaded database does) and also display in the other Combo Boxes the text for the selected record. This can be done and I have uploaded a modified version of your database. It is just an indication of how it can be done and only changes the Phone Combo Box. The information to set the Combo Box is available in the Fields below the Combo Boxes and my change just copies the text from the Phone text field to the Phone Combi Box.

There is however a simpler method to achieve the record display from a Combo Box selection by uaing a Form Filter. I have added Form2 to your database which uses this method and it updates all the Combi Boxes. It should be quicker especially on a large Table. Your method requires two searches of the Table using Queries. There is also a potential problem with your method as only the Customer_ID field is guarenteed to be unique as it is the Primary Key. You could have duplicates in the other Fields. If there is more than one match for the selection to find the ID your method will only show the first match. With my filter method if there is more than one match the record selector will show that there is more than one match.

1484562805458959MOD.odb

@Peterwt, Thanks, I still have much more investigating to do, but first off I’m getting an error message from oPhone.Text in your .odb as follows (what version of LO are you running?):

LibreOffice 5.2.3.3

(-) BASIC runtime error.
Property or method not found: Text.