Topic: Script so that you force an answer in Combobox.

Does this make any sense ?

      fform.combobox1.dbSQLExecute('SELECT id FROM dbClientName WHERE id='+fmClientsSearch.TableGrid1.sqlValue);   


I'd like to basically force an answer into a combo box, as I am limited in my programming skills, this would be a quick loop around  my problem.

(p.s. what is in the fmclientSearch.TableGrid would be the same list that would be available in the combo box)


Help and thanks to anyone.

Re: Script so that you force an answer in Combobox.

Hi Jeff,
Not sure if I quite understand what you're trying to do, but you could try it this way (eliminates unnecessary sql call).
Derek.

Post's attachments

Attachment icon jeff.zip 336.68 kb, 245 downloads since 2021-10-23 

Re: Script so that you force an answer in Combobox.

Hi Derek

The idea is correct, but it wouldn't be the id but the name.
I was under the impression that giving the ID to the combo box would; give me text assigned to the TEXT

So when I open a form, based on a previous grid, the Name of the selected grid would appear in the combobox.



.

4 (edited by derek 2021-10-23 20:01:41)

Re: Script so that you force an answer in Combobox.

Hi Jeff,
It's an easy fix.
The script stays the same because it is the id from the tablegrid that you are using to link with the id of the combobox.
Once you have the link, you then choose to display whatever field you want in the combobox (or multiple fields (and literals)).
All you need to change is the field that you want to display in the combobox (see the screenshot in the attachment).
It's easier to follow if you see it working so, in the attached example, I've used 3 discrete comboboxes to show different combinations.
Derek.

Post's attachments

Attachment icon jeff2.zip 487.11 kb, 251 downloads since 2021-10-23 

Re: Script so that you force an answer in Combobox.

Ohhh my god..   So simple and elegant.  Once again I was over thinking this problem.
Programming is an ART.

Thank you Derek this will bring what I am doing to a higher level, with such simplify.

Re: Script so that you force an answer in Combobox.

On the same Theme

Is it possible to not refer to a grid but tell the combobox of the value you want.(Knowing that the value exists in the selection field).

Here is an example but I tried it but didnt work.


procedure fmGroupPresence_OnShow (Sender: TObject; Action: string);

     Begin
          fmGroupPresence.ProgressType.dbitemid:='For closure';
     end;

7 (edited by derek 2021-10-24 00:11:30)

Re: Script so that you force an answer in Combobox.

Hi Jeff,
So in effect, you want to pre-set the combobox with a certain value but then have the option to go into the combobox and select different values.
Using the earlier example, you could do it something like this (see attachment).
Derek.

Post's attachments

Attachment icon jeff3.zip 487.1 kb, 286 downloads since 2021-10-24