Page 1 of 1

Delete Field Bug

Posted: Fri 05 Feb 2010 12:45
by m227
Hello Friends.

How to delete field from VirtualTable in runtime?
All functions below:

Code: Select all

  with BA.FieldDefs do Delete( IndexOf('aktywne') );
  TVirtualTable(BA).DeleteField('aktywne');
  BA.FieldDefs.Find('aktywne').Free;
  BA.FieldDefs[BA.FieldDefs.IndexOf('aktywne')].Destroy;
seem to free values at most, leaving field in table.

any help?

Posted: Mon 08 Feb 2010 08:38
by Plash
You can use the following code:

Code: Select all

  VirtualTable1.Close;
  VirtualTable1.DeleteField('aktywne');
  VirtualTable1aktywne.DataSet := nil;
  VirtualTable1.Open;

Posted: Mon 08 Feb 2010 10:38
by m227
I am afraid it does not work in my case.
My VirtualTable was assigned from other VT:

Code: Select all

    BA := TVirtualTable.Create(Self);
    BA.Assign(vtBadanie);
So I have no names of fields like VirtualTable1aktywne to nullify its DataSet property.

And without this line it does not work again.

Posted: Tue 09 Feb 2010 08:40
by Plash
Use FieldByName('aktywne')

Posted: Tue 09 Feb 2010 09:46
by m227
Thank you,

Now it works flawelessly. It suits me fine. Only question is if wouldn't it be better to use simple line as i.e. DeleteField, instead for four lines of code?
Of course I can make myself some function but nice have it made internally.

Thanks again.
Michal.