Programming Guide : Creating Dynamic Frames : How You Can Remove Fields Dynamically : How You Can Remove Columns from a Table Field
 
Share this page          
How You Can Remove Columns from a Table Field
To remove a column from a table field, use the DeleteColumn method. For example, the following statement deletes the second column from a table field named tblfld:
tblfld.DeleteColumn(position = 2);
Because table fields must always contain at least one column, you can never delete all columns from a table field. Therefore, replacing all of a table field's columns with another set of columns requires the following steps:
1. Delete all but one column.
2. Add the new columns.
3. Remove the last of the original columns.
The following code performs these operations:
for i = tfield.TableBody.ChildFields.LastRow downto
    2 do tfield.DeleteColumn(position = i);
endfor;
   insert new columns, beginning with position 1
tfield.DeleteColumn(position =
    tfield.TableBody.ChildFields.LastRow);