Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnCalcfields event for virtual table

Status
Not open for further replies.

msgopala

Programmer
Oct 30, 2008
43
US
Delphi 7

Have an oncalcfields event for a virtual table column in a dbgrid. This event wont fire at all.

I can get it to work by putting the code in a browsegridcolexit event, but the problem with that the field gets cleared everytime user exits and unless user re-tabs over certain columns the calculated field is left blank (which is correct).

I have ensured that the calculated field is a persistent field in the fields editor of my virtual table.

Virtual table proprty autocalcfields is set to true.


my procs are as follows...

procedure Tform1.SchdTempTableCalcFields(DataSet: TDataSet);
begin
with datamodule do
if table1.ADSSeek(SInteger(table2.FieldByName('CO').AsInteger,1)+
SInteger(table2.FieldByName('PO').AsInteger,8)+
SInteger(table2.FieldByName('SE').AsInteger,2)+
SInteger(SchdTempTable.FieldByName('LO').AsInteger,3),stHARD) then
if Covunit.ADSSeek(SInteger(table2.FieldByName('CO').AsInteger,1)+
SInteger(table2.FieldByName('PO').AsInteger,8)+
SInteger(table2.FieldByName('SE').AsInteger,2)+
SInteger(SchdTempTable.FieldByName('LO').AsInteger,3)+
SInteger(SchdTempTable.FieldByName('COV').AsInteger,3),stHARD) then
SchdTempTable.FieldByName('LODESC').AsString := table1.FieldByName('ADD').AsString+'/'+
table3.FieldByName('DES').AsString
else
SchdTempTable.FieldByName('LODES').AsString := table1.FieldByName('ADD').AsString;
end;

Appreciate all your help in advance.


msgopala
 
When you say Virtual table are you creating the table in memory but you have dropped a component on your form? Or are you creating the table object in code as well?
 
Yes I have dropped a component and creating the calc field via fields editor but the other fields in code.

msgopala
 
When the application is running - can you see if your autocalcfields option is still set to True?
 
Perhaps try dynamically generating your calculated columns after you've opened the dataset.
 
DMan,

Thanks. Thought about what you said and ended up having a oncolexit to calc and display when adding new recs and an onenter event to display, if just view the grid.

:) tx again

M

msgopala
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top