Topic: Index number from a list of values.

Hello,
Have struggled with this for a while now, so i really need some help.

I have a Field/Combox in a form with some data:

Sweden
Canada
Germany
France
Norway
Denmark

The number of values in the list increases when a i add a new country.
What i need is a way to find the Item Index for a Value.

InForm.Combobox3.ItemIndex := 4; would fill in the ComboBox3 with the value *France'

But if i want to go the other way and find the Itemindex for 'Norway'. Is that possible?

Thanks in advance

2 (edited by derek 2019-07-15 09:25:16)

Re: Index number from a list of values.

Hi Hedan,
Not sure if I understand your question correctly, but does the attached help at all?
When you display your combobox, you can concatenate a number of fields together (enclose each one in { }). 
So in your example, you can show both the record id and the country.
If you then make the combobox searchable, when you add or edit, you can either enter an ID or value to select the correct record.
Derek.

Post's attachments

Attachment icon hedan.zip 338.34 kb, 303 downloads since 2019-07-15 

Re: Index number from a list of values.

Hi derek,

I have enclosed an example to show what i´m Trying to achieve.

When you open a record there is a button "Show - Show all from the above country" who will display all records from the  field 'Country" in the form.

Maybe there is a better way to do this, but....

Hope you understand me...

Re: Index number from a list of values.

Sorry forgot the ZIP-file

Post's attachments

Attachment icon Hedan2.zip 334.99 kb, 326 downloads since 2019-07-15 

Re: Index number from a list of values.

Hedan,

In your case just change the line Show.ComboBox1.ItemIndex := 1;  to Show.ComboBox1.dbItemID := Form1.ComboBox1.dbItemID;


Not sure how your project is suppose to work, but you could do the search on your first form instead of the Show form.