1 (edited by v_pozidis 2016-12-01 20:30:46)

Topic: How can I show in combobox the values when i select from TableGrid?

How can I show in combobox the values  when i select from TableGrid?
I know only how it works with TextBox but not with ComboBox.
I know the following script but this is only for  text box.

s := SQLExecute('SELECT LastName from names WHERE id=' + IntToStr( Form1.TableGrid1.dbItemID));
         Form1.Edit1.Text := s;

I attached my example.

Post's attachments

Attachment icon example.7z 275.15 kb, 474 downloads since 2016-12-01 

Re: How can I show in combobox the values when i select from TableGrid?

Hello v_pozidis,
I have added the line to your script to show how this can be done.
I have also changed your script a bit - you don't actually need to use a variable ('s'), you can just select the value directly into the field (edit1, edit2, combobox1 etc).
I hope this helps,
Derek.

Post's attachments

Attachment icon example.zip 337.61 kb, 556 downloads since 2016-12-02 

Re: How can I show in combobox the values when i select from TableGrid?

Thank you derek. Works fine. It was exact waht I asked.

4 (edited by v_pozidis 2016-12-03 09:57:47)

Re: How can I show in combobox the values when i select from TableGrid?

What if  we have and another combobox that is a PaerntCombobox how does it works there ?
My new example is attached added with another combobox.
Derek I need again your help.
Thank you friend.

Post's attachments

Attachment icon example2.7z 275.75 kb, 467 downloads since 2016-12-03 

Re: How can I show in combobox the values when i select from TableGrid?

v_pozidis
Please download your project.


Also I made some changes in your database structure.

Post's attachments

Attachment icon example2_fixed.zip 6.32 kb, 536 downloads since 2016-12-05 

Dmitry.

Re: How can I show in combobox the values when i select from TableGrid?

I Couldn't think this solution.Thank's Dmitry.

7 (edited by v_pozidis 2017-07-16 12:56:56)

Re: How can I show in combobox the values when i select from TableGrid?

how can I do the same when I add two  more table?
It should be Country - City - Area- Zip
In the attached file is my new example (I have just add only the comboboxes and the rest is like you have send me)

Post's attachments

Attachment icon example2_fixed (new).zip 337.49 kb, 432 downloads since 2017-07-16 

Re: How can I show in combobox the values when i select from TableGrid?

help needed please!!!

Re: How can I show in combobox the values when i select from TableGrid?

v_pozidis
Unfortunately in your example there is no database table for Country and zip field, please make correct example with right database structure.

Dmitry.

10 (edited by v_pozidis 2017-07-20 16:53:22)

Re: How can I show in combobox the values when i select from TableGrid?

I RESEND YOU MY EXAMPLE WITH THE TWO NEW TABLES AND I HAVE ALSO CREATEED THE FORM HOW I WANT THEM.

Post's attachments

Attachment icon example2_fixed(new1).zip 338.56 kb, 430 downloads since 2017-07-20 

Re: How can I show in combobox the values when i select from TableGrid?

Waiting for your help Dmitry.

Re: How can I show in combobox the values when i select from TableGrid?

v_pozidis wrote:

Waiting for your help Dmitry.

Check it out

Post's attachments

Attachment icon example2_fixed_fixed.zip 8.56 kb, 449 downloads since 2017-07-25 

Dmitry.

Re: How can I show in combobox the values when i select from TableGrid?

Thank you.

14 (edited by v_pozidis 2017-07-28 17:21:46)

Re: How can I show in combobox the values when i select from TableGrid?

I have added a search button. It works only when I choose all the comboboxes. It does't works choosing separately comboboxes. Let's say I like to search the country only or the country and the city.I send you my software to help me again.

Post's attachments

Attachment icon example2_fixed_fixed(3).zip 339.67 kb, 389 downloads since 2017-07-28 

Re: How can I show in combobox the values when i select from TableGrid?

v_pozidis wrote:

I have added a search button. It works only when I choose all the comboboxes. It does't works choosing separately comboboxes. Let's say I like to search the country only or the country and the city.I send you my software to help me again.

In this case you should use SQL to search, example:

Post's attachments

Attachment icon example2_fixed_fixed(4).zip 9.56 kb, 413 downloads since 2017-07-31 

Dmitry.

16 (edited by v_pozidis 2017-08-01 04:21:10)

Re: How can I show in combobox the values when i select from TableGrid?

But when I search in the Editbox it doesn't work, It works only with the comboboxes. And another question in case a add table work with relationship on names how does it works on the sql search ? Sorry can not send you example something happens on my pc and doesn't boot writting on android tablet

Is this correct
WHERE

names.LastName lLike {Edit1} AND
(CASE WHEN {Wo} <> -1 THEN Work.id_Work = {Wo} ELSE 1=1 END) AND

(CASE WHEN {cbZip} <> -1 THEN names.id_Tk = {cbZip} ELSE 1=1 END) AND
(CASE WHEN {cbArea} <> -1 THEN Tk.id_Area = {cbArea} ELSE 1=1 END) AND
(CASE WHEN {cbCity} <> -1 THEN Area.id_City = {cbCity} ELSE 1=1 END) AND
(CASE WHEN {cbCountry} <> -1 THEN City.id_Countr = {cbCountry} ELSE 1=1 END)

Re: How can I show in combobox the values when i select from TableGrid?

v_pozidis wrote:

But when I search in the Editbox it doesn't work, It works only with the comboboxes.


Example:
http://myvisualdatabase.com/forum/misc. … download=1


v_pozidis wrote:

And another question in case a add table work with relationship on names how does it works on the sql search ? Sorry can not send you example something happens on my pc and doesn't boot writting on android tablet

Please send me updated project with work table

Dmitry.

18 (edited by v_pozidis 2017-08-03 04:31:28)

Re: How can I show in combobox the values when i select from TableGrid?

Updated, my new example is the attached file. I have added a new table Work. In the SQL Search button it should work also wih the edit boxex and the new combobox (Work).

Post's attachments

Attachment icon example2_fixed_fixed(5).zip 340.52 kb, 408 downloads since 2017-08-01 

Re: How can I show in combobox the values when i select from TableGrid?

v_pozidis wrote:

Updated, my new example is the attached file. I have added a new table Work. In the SQL Search button it should work also wih the edit boxex and the new combobox (Work).

Fixed project

Post's attachments

Attachment icon example2_fixed_fixed(6).zip 10.15 kb, 439 downloads since 2017-08-03 

Dmitry.

20 (edited by v_pozidis 2017-08-07 19:23:14)

Re: How can I show in combobox the values when i select from TableGrid?

Because I am not sure if the new lines I have added in the paragraph //new lines which you will see in my project. Can you confirm  if they are correct ?




s := SQLExecute('SELECT Lastname from names WHERE id=' + IntToStr(Form1.TableGrid1.dbItemID));
    Form1.edLastName.Text := s;

    s := SQLExecute('SELECT SName from names WHERE id=' + IntToStr(Form1.TableGrid1.dbItemID));
    Form1.edSName.Text := s;

  Form1.cbWork.dbitemid := SQLExecute('select names.id_Work from Work LEFT OUTER JOIN names ON names.id_Work = Work.id WHERE names.id='+ Form1.tablegrid1.sqlValue);

Post's attachments

Attachment icon example2_fixed_fixed(7).zip 341.12 kb, 527 downloads since 2017-08-07 

Re: How can I show in combobox the values when i select from TableGrid?

It's correct.

Dmitry.

Re: How can I show in combobox the values when i select from TableGrid?

Thank you.