Jump to content
Sign in to follow this  
tobenschain

addng a field to an existing file

Recommended Posts

I'm trying to add a field to an existing file with four fields.

BudSys_DB.Active := true;

BudSys_DB.FieldDefs.Add('Amount',ftFloat, 0);

BudSys_DB.FieldDefs.Count goes up but

BudSys_DB.Fields.Count stays at four

BudSys_DB.Fields[3+1].AsFloat := amount;

Gives: Project BudGen6.exe raised exception class EDatabaseError with message 'List index out of bounds (6).  TFields range is 0..3'.
 

Share this post


Link to post

Try after the add

 

BudSys_DB.FieldDefs[4].CreateField(BudSys_DB);

 

or

 

Private:

AmountField : TFloatField;

 

Implementation:

 

AmountField := TFloatField.Create(BudSys_DB);
AmountField .FieldName := 'Amount';
AmountField .Calculated := True;
AmountField .DataSet := BudSys_DB;
AmountField .Name := BudSys_DB.Name + AmountField .FieldName;

BudSys_DB.FieldDefs.Add('Amount',ftFloat, 0);

 

Destroy:

AmountField.Free;

 

Edited by Die Holländer

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×