Evento OnCalcFields. Como usá-lo?
Estou tentando usar o evento OnCalcFields em Tabela Paradox mas esta dando o seguinte erro:
[Error] Unit1.pas(57): Incompatible types
[Fatal Error] Project2.dpr(5): Could not compile used unit ´Unit1.pas´
estou usando Delphi 7 e Paradox os Campos em questão são todos do tipo S.
Se alguem puder ajudar - Sou iniciante
Segue o código do programa:
[Error] Unit1.pas(57): Incompatible types
[Fatal Error] Project2.dpr(5): Could not compile used unit ´Unit1.pas´
estou usando Delphi 7 e Paradox os Campos em questão são todos do tipo S.
Se alguem puder ajudar - Sou iniciante
Segue o código do programa:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Mask, DBCtrls, DB, DBTables; type TForm1 = class(TForm) Table1: TTable; DataSource1: TDataSource; Table1RELOGIO: TStringField; Table1CONSUMIDOR: TStringField; Table1PRECO_KILOWATE: TCurrencyField; Table1LEITURA_ANTERIOR: TSmallintField; Table1LEITURA_ATUAL: TSmallintField; Table1CONSUMO_TOTAL: TSmallintField; Table1CONSUMO_EXCEDIDO: TSmallintField; Table1TOTAL_DA_FATURA: TSmallintField; Table1DATA: TDateField; Label1: TLabel; DBEdit1: TDBEdit; Label2: TLabel; DBEdit2: TDBEdit; Label3: TLabel; DBEdit3: TDBEdit; Label4: TLabel; DBEdit4: TDBEdit; Label5: TLabel; DBEdit5: TDBEdit; Label6: TLabel; DBEdit6: TDBEdit; Label7: TLabel; DBEdit7: TDBEdit; Label8: TLabel; DBEdit8: TDBEdit; Label9: TLabel; DBEdit9: TDBEdit; Table1TOTAL: TIntegerField; procedure Table1CalcFields(DataSet: TDataSet); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Table1CalcFields(DataSet: TDataSet); begin Table1CONSUMO_TOTAL :=Table1LEITURA_ANTERIOR+Table1LEITURA_ATUAL; end; end.
Ciro_cj
Curtidas 0
Respostas
Vinicius2k
22/03/2006
Colega,
Atenção ao [b:61fb25469b].Value[/b:61fb25469b] que é a propriedade do TField que contém o valor, propriamente dito.
Table1CONSUMO_TOTAL.Value := Table1LEITURA_ANTERIOR.Value + Table1LEITURA_ATUAL.Value;
Atenção ao [b:61fb25469b].Value[/b:61fb25469b] que é a propriedade do TField que contém o valor, propriamente dito.
GOSTEI 0
Paullsoftware
22/03/2006
só um detalhe, para funcionar você deve chamar o Fields Editor da Tabela (clique doplo sobre ela) selecionar os campos que serão calculados ir no Object Inspector e na pripriedade Field King = FkData mude para [b:d4512a2215]fkCalculated[/b:d4512a2215] e depois é só usar normalemente o campo no OnCalcFields como já foi mostrada anteriormente:
:wink:
Table1CONSUMO_TOTAL.Value := Table1LEITURA_ANTERIOR.Value + Table1LEITURA_ATUAL.Value;
GOSTEI 0
Barretoee
22/03/2006
valew galera, esse forum ta me ajudando pra karamba..... muito bom
GOSTEI 0