I am preparing a CRUD in Delphi and need to do a function to find the key field ( KeyField ) of a particular record located in the query. The idea is to replace the 'id' field required by the Locate with this function and leave the dataset set up to take any query on the inherited forms. I'll demonstrate the code to see if they understand me:
ds_Crud.DataSet.Locate('tpdoc_id',ds_Query.DataSet.FieldByName('tpdoc_id').Value,[loCaseInsensitive,loPartialKey]);
My data tabsheet for this form is triggered when the record is located by ds_Query and is located by the primary key in ds_Crud that goes into edit mode to perform EDIT or EXCLUSION.
The problem is that I can not enter the 'id' code every time I query in inherited forms, I need a function that returns the key field name to filter the record in the CRUD DataSet, which is virtual and abstract of type ( function GetNomeKeyFiled: String;virtual;abstract;
) to assume the position of 'tpdoc_id' in the code line above locate, or something that solves this problem.