Henry Olive 5 Posted July 16, 2021 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
corneliusdavid 214 Posted July 16, 2021 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
Lajos Juhász 293 Posted July 16, 2021 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
Henry Olive 5 Posted July 16, 2021 Thank you so much Corneli dm.OrdersDOCNO.OnChange := nil; dm.OrdersDOCNO.OnChange := OrdersDOCNOChange; works Share this post Link to post
corneliusdavid 214 Posted July 16, 2021 (edited) 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 July 16, 2021 by corneliusdavid Share this post Link to post
Lajos Juhász 293 Posted July 16, 2021 (edited) 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 July 16, 2021 by Lajos Juhász Share this post Link to post