How to get the currently edited ("active") field ------------------------------------------------ USES ..........., TypInfo; function IsDBControl(AC :tControl; VAR Datasource: tdataSource):Boolean; { Tells whether AC is data aware control. The routine logic is this: data aware control is the control that does have DataSource property that is either NIL or tdataSource. Should work in well behaved DB controls } var ptrPropInfo : PPropInfo; Begin Result := false; if AC <> NIL then Begin ptrPropInfo := GetPropInfo(AC.ClassInfo, 'DataSource'); if (ptrPropInfo <> nil) And (ptrPropInfo^.PropType^.Kind = tkClass) then Begin DataSource := Pointer(GetOrdProp(AC , ptrPropInfo)); result := (DataSource = NIL) or (DataSource Is tdataSource); End; End End; Function GetActiveField(Form: tForm): tField; { Returns Field that is currently edited. The routine logic is this: if user edits a field, the active control of the form is DB control connected to that field. It also assumes that the DB control is either CustomDBGrid or does have a string property DATAFIELD that holds the name of the managed field } Var Datasource : tDatasource; ptrPropInfo : PPropInfo; AC : tControl; Begin Result := NIL; if Form <> NIL Then Begin AC := Form.ActiveControl; If IsDBControl(AC,Datasource) And (Datasource <> NIL) And (Datasource.Dataset <> NIL) Then Begin If AC Is tCustomDBGrid Then Result := (AC As tCustomDBGrid).SelectedField Else Begin ptrPropInfo := GetPropInfo(AC.ClassInfo, 'DataField'); If (ptrPropInfo <> nil) And (ptrPropInfo^.PropType^.Kind = tkLString) {Huge string} Then Result := Datasource.Dataset.FindField(GetStrProp(AC, ptrPropInfo)); End End End End; { The above routine gets the field corresponding to the active control on the particular form. Each opened form could have one. To find the unique "active" field for the application, use " GetActiveField(Screen.ActiveForm) " call }