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???

Delphi

Avatar of undefined
Last Comment
mc94051

8/22/2022 - Mon
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;
Limbeck

..after the all, the validation is related to the table, not the editbox. either that or  write the val. code in the onexit event.
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
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER CERTIFIED SOLUTION
kretzschmar

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
mc94051

ASKER
Worked like a dream meikl, thanks a lot.