Link to home
Start Free TrialLog in
Avatar of mc94051
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(AOwner: TComponent);
    Self.DataSource.DataSet.BeforePost := DBEditBeforePost;
end;

procedure customcomponent.DBEditBeforePost(DataSet: TDataSet);
    Code X;
end;

Then I go on a form with the customcomponent on it and a TTable with name "aTable":

procedure TfrmPurchaseOrder.aTableBeforePost(DataSet: 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???

Avatar of Limbeck
Limbeck

might not be a good idea to have the before post set by a component

why not the easy way, in the beforepost of the table

if table1.FieldByName('').value<>table1.fieldbyname('').OldValue then
  codex;
codeY;
..after the all, the validation is related to the table, not the editbox. either that or  write the val. code in the onexit event.
Avatar of mc94051

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
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mc94051

ASKER

Worked like a dream meikl, thanks a lot.