mc94051
asked on
BeforePost Event
Hi everyone,
I have a problem with a custom component I 've made consisting of a TButton and a TDBEdit. I have some code which does some validation and I want it to apply to all instances of my control. I do this on the BeforePostEvent of the control's dataset with the following code in the constructor of my component:
constructor customcomponent.Create(AOw ner: TComponent);
Self.DataSource.DataSet.Be forePost := DBEditBeforePost;
end;
procedure customcomponent.DBEditBefo rePost(Dat aSet: TDataSet);
Code X;
end;
Then I go on a form with the customcomponent on it and a TTable with name "aTable":
procedure TfrmPurchaseOrder.aTableBe forePost(D ataSet: TDataSet);
begin
inherited;
Code Y;
end;
My problem with this is that when I assign some code in the BeforePost event of the form containing my component although "inherited" is there the form's code is not executed (Code Y in the example) but only the component's (Code X in the example). Is there anything I can do to execute 'Code X' via the inherited and 'Code Y' next???
I have a problem with a custom component I 've made consisting of a TButton and a TDBEdit. I have some code which does some validation and I want it to apply to all instances of my control. I do this on the BeforePostEvent of the control's dataset with the following code in the constructor of my component:
constructor customcomponent.Create(AOw
Self.DataSource.DataSet.Be
end;
procedure customcomponent.DBEditBefo
Code X;
end;
Then I go on a form with the customcomponent on it and a TTable with name "aTable":
procedure TfrmPurchaseOrder.aTableBe
begin
inherited;
Code Y;
end;
My problem with this is that when I assign some code in the BeforePost event of the form containing my component although "inherited" is there the form's code is not executed (Code Y in the example) but only the component's (Code X in the example). Is there anything I can do to execute 'Code X' via the inherited and 'Code Y' next???
..after the all, the validation is related to the table, not the editbox. either that or write the val. code in the onexit event.
ASKER
My problem is that CodeX is generic and I want it always executed whereas CodeY is form specific.
I would have to insert CodeX everywhere which is repetitive without reason if I can do it the way I try
On Exit is not good because u can post without exit
I would have to insert CodeX everywhere which is repetitive without reason if I can do it the way I try
On Exit is not good because u can post without exit
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Worked like a dream meikl, thanks a lot.
why not the easy way, in the beforepost of the table
if table1.FieldByName('').val
codex;
codeY;