1 (edited by Step-in 2023-12-11 14:51:13)

Topic: [Solved] Subtable in a combobox

Hello. Help please. How can I display information from a subtable in a combobox? I need to display the street's category without creating additional comboboxes.This solution does not work : {StreetCat.Name}{StreetName} in frmAddPayee.

Post's attachments

Attachment icon PaymentsRegister.zip 335.73 kb, 35 downloads since 2023-11-22 

Re: [Solved] Subtable in a combobox

You can add a calculated field and use it in a dropdown list.

Post's attachments

Attachment icon PaymentsRegister.rar 295.25 kb, 79 downloads since 2023-11-22 

Визуальное программирование: блог и телеграм-канал.

Re: [Solved] Subtable in a combobox

Oh, how simple everything is. Thanks a lot for the tip.

Re: [Solved] Subtable in a combobox

Same project with minor changes in directories. The problems are as follows:
1) Fields in the TableGrid are duplicated relative to the number of regions.
2) When copying a row, all ComboBoxes are not filled.

My opinion... That the fields are duplicated because the data structure is incorrect, but I won't be able to organize them differently (such relationships). When copying data, the script is incorrect, because such a field does not exist in TableGrid. But how should I write the region field in TableGrid and work with this data? Calculated field don't work.
In my project, ComboBoxes are dependent. Asking for help from experts...

Post's attachments

Attachment icon PaymentsRegister.zip 337.62 kb, 24 downloads since 2023-11-23 

5 (edited by k245 2023-11-23 08:53:32)

Re: [Solved] Subtable in a combobox

MVDB does not work well if the nesting depth when setting up a table exceeds 2. In your case, it is enough to replace the nested table with a calculated field smile


https://myvisualdatabase.com/forum/misc.php?action=pun_attachment&item=10104&download=0

Post's attachments

Attachment icon изображение_2023-11-23_115018424.png 81.4 kb, 12 downloads since 2023-11-23 

Визуальное программирование: блог и телеграм-канал.

Re: [Solved] Subtable in a combobox

project

Post's attachments

Attachment icon PaymentsRegister.rar 296.95 kb, 52 downloads since 2023-11-23 

Визуальное программирование: блог и телеграм-канал.

7 (edited by k245 2023-11-23 08:56:05)

Re: [Solved] Subtable in a combobox

result
https://myvisualdatabase.com/forum/misc.php?action=pun_attachment&item=10106&download=0

Post's attachments

Attachment icon изображение_2023-11-23_115544319.png 13.84 kb, 13 downloads since 2023-11-23 

Визуальное программирование: блог и телеграм-канал.

8 (edited by Step-in 2023-11-23 09:52:00)

Re: [Solved] Subtable in a combobox

And again, a huge thank you.

Step-in wrote:

2) When copying a row, all ComboBoxes are not filled.

And what can you say about opening the creation form and filling it with data regarding the placement of the highlighted line?

Re: [Solved] Subtable in a combobox

If do not use the ParentComboBox on form frmAddPayee  - the street is copied (img). The region always remains empty. Is it possible to leave one form frmAddPayee for New Record and New Copy Record?

P.S. I need ParentComboBox.

Post's attachments

Attachment icon test_copy.JPG 47.48 kb, 14 downloads since 2023-11-23 

Re: [Solved] Subtable in a combobox

The script should run after the editing form opens.

procedure frmAddPayee_OnShow (Sender: TObject; Action: string);
var
  IDStreet : integer;
  IDRegion : integer;
begin
  if Action = 'ShowForm' then
  begin
    if (SearchPayments.TableGrid1.SelectedRow>=0) then
    begin
      IDStreet := SQLExecute('SELECT PayeeRegister.id_Street FROM PayeeRegister WHERE id='+ IntToStr(SearchPayments.TableGrid1.dbItemID) );
      IDRegion := SQLExecute('SELECT Street.id_Region FROM Street WHERE id='+ IntToStr(IDStreet) );
      frmAddPayee.ComboBox2.dbitemid := IDRegion;
      frmAddPayee.ComboBox2.DoOnChange;
      frmAddPayee.ComboBox1.dbitemid := IDStreet;

      frmAddPayee.Edit1.Text := SQLExecute('SELECT "'+ frmAddPayee.Edit1.dbField +'" FROM PayeeRegister WHERE id='+ IntToStr(SearchPayments.TableGrid1.dbItemID) );
      frmAddPayee.Edit2.Text := SQLExecute('SELECT "'+ frmAddPayee.Edit2.dbField +'" FROM PayeeRegister WHERE id='+ IntToStr(SearchPayments.TableGrid1.dbItemID) );
    end;
  end;
end;
Post's attachments

Attachment icon PaymentsRegister.rar 297.11 kb, 59 downloads since 2023-11-24 

Визуальное программирование: блог и телеграм-канал.

Re: [Solved] Subtable in a combobox

Thank you again and thank you 100 times more. With these changes everything works, but rather slowly.