Jump to content
Henry Olive

Disable & re-Enable a Procedure

Recommended Posts

I wish everyone a healthy day.
 

I have below procedure

procedure TDm.OrdersDOCNOChange(Sender: TField);
begin
....

end;

 

How can i disable & re-enable this proc.?

I tried   dm.Orders.DOCNOChange := Nil; //  Err.Msg = Undeclared identifier: 'DOCNOChange'

 

Thank You

 

 

Share this post


Link to post

So I gather you have a data module with an Orders table or query where one of the fields is DOCNO and you double-clicked on the OnChange event handler in the Object Inspector to create the procedure.

 

So to clear it at runtime in code you would clear the OnChange property of the DOCNO field. In other words, you were very close:

dm.Orders.DOCNO.OnChange := nil;

And you would hook it back up again by reassigning the created procedure name:

dm.Orders.DOCNO.OnChange := OrdersDOCNOChange;

 

Share this post


Link to post
4 minutes ago, corneliusdavid said:

dm.Orders.DOCNO.OnChange := OrdersDOCNOChange;

 

OrdersDOCNOChange is part of the datamodul:

 

dm.Orders.DOCNO.OnChange := dm.OrdersDOCNOChange;

 

 

Share this post


Link to post

Thank you so much Corneli

dm.OrdersDOCNO.OnChange := nil

dm.OrdersDOCNO.OnChange := OrdersDOCNOChange;

works

 

 

Share this post


Link to post

Lajos, Yes, but if you're enabling/disabling from within the data module you don't need to preface it with the variable name.

Edited by corneliusdavid

Share this post


Link to post
49 minutes ago, corneliusdavid said:

Lajos, Yes, but if you're enabling/disabling from within the data module you don't need to preface it with the variable name.

But you references the object as dm.Orders.Docno with dm that would suggest that it was from outside.

 

In this case it should be:

 

OrdersDOCNO.OnChange := nil

OrdersDOCNO.OnChange := OrdersDOCNOChange;

 

Edited by Lajos Juhász

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×