Ask Your Question

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

asked 2017-01-16 11:37:27 +0200

EasyTrieve gravatar image

updated 2017-01-16 11:38:33 +0200

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,


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:


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.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-09-20 23:33:25.517770

2 Answers

Sort by » oldest newest most voted

answered 2017-01-16 20:12:01 +0200

EasyTrieve gravatar image
thisComponent.getCurrentController().getControl(oEvent.Source.getByName("target control name")).Text = "some text"
edit flag offensive delete link more

answered 2017-01-18 18:12:21 +0200

peterwt gravatar image

@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.


edit flag offensive delete link more


@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?):


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

EasyTrieve gravatar imageEasyTrieve ( 2017-01-18 23:21:53 +0200 )edit

Question Tools

1 follower


Asked: 2017-01-16 11:37:27 +0200

Seen: 1,082 times

Last updated: Jan 18 '17