Topic: combo box items

how to put item from any table using sqlexecute query..

Re: combo box items

Hello blackpearl

You could use this piece of code (and adapt it to your case)

Form1.Combobox1.dbSQLExecute('Select distinct (MyfFeld) from (MyTable');

(as I already use this code in one of my projects, I added the  keyword DISTINCT to avoid repeating duplicates on the MyField field).

To put behind a FormShow event for example, or behind any other event requiring this result (ButtonClick,, CheckBoxChecker ...

Hope this can help you

JB

Re: combo box items

jean. blackpearl8534,
You should also include "id" in the SELECT so you know what the id is for the specific selection in the combobox.

4 (edited by derek 2020-02-18 23:49:31)

Re: combo box items

Hi Everyone,
You can also just manually type in ANY tablename (in the 'foreign key' property) and ANY fieldname (in the 'fieldname' property) - please see the attached screen shot.
It's quick and easy but obviously it doesn't give you the option to have just distinct records (as Jean's code does) nor does it know anything about the record's "id" (as EHW rightly points out).
Derek.

Post's attachments

Attachment icon combobox cheat.jpg 116.9 kb, 135 downloads since 2020-02-19 

Re: combo box items

Good suggestion Derek. Actually using your method does provide the record's id through retrieving dbItemID in script.


I should have clarified a little more in my answer. It really depends on how the combobox is to be used. If it's being used as a type of lookup as normally done in MVD then placing the id in the SELECT statement should be present. However, I have done the same thing as Jean mentioned with using DISTINCT in the SELECT in situations where I did not need the id. In fact you can't put the id in the SELECT statement when using DISTINCT because it actually defeats the purpose of distinct.

Re: combo box items

hello derek.. thanks for help. i know how to configure combobox usin controls..
i want to load data from table into combobox using script..