Add columns by another table rows.

Hi all,

Is that any way to add columns in one table by another table rows.

ex: i have created a table “Test” and i have a navsion table SalesPerson,. Now i want that when i add a new sales person, that sales person should add automatically in the Test table as a new column.

Is that any way?
Thank you.

Regards

Do you mean new column means new field ?

Yes

You can try this code in OnInsert trigger of Sales Person/Purchaser table.

Field.RESET;

Field.SETRANGE(TableNo,69000);

IF Field.FINDLAST THEN BEGIN

Field.INIT;

Field.“No.” := Field.“No.” + 1;

Field.FieldName := Code;

Field.Type := Field.Type::Code;

Field.Len := 20;

Field.Enabled := TRUE;

Field.INSERT;

END;

Where field is a record type variable of type Field

No, that’s a really silly idea. If you are trying to setup a relation table then create a table with a primary key of salesperson code and add code to the OnInsert / OnRename triggers of the salesperson table.

In the scenario you describe, you could easily run out of fields. There is a limited record size. If you need a new Field, manually add it via Object Designer. If you need data automatically populated in a field, you should use the correct triggers.