@Zvoni as for the logic of the code, a conditional statement is enough?
Pretty much.
Don't get me wrong: Using DB-bound Controls is a viable way, it's just that in basically 25 years i've never used them, since i like to have control over what is happening.
So if you want to do it yourself:
I have a Variable which is valid for the scope of the Form (could be "global", could be a property of the Form, of a Class i use there, whatever).
This variable is "out of the gates" always first in Update-Mode (or if i use an Enum the third state: Undefined).
Click on the Grid (selecting a record) definitely switches the Update-Mode on. Change what you have to change (i use separate TEdit's for that). Click on Save, DB gets UPDATED.
Click on "New"-Button: Switch to INSERT-Mode, clear the TEDit's, enter new Data, hit Save, record gets INSERTED into DB.
In both cases, when hitting "Save" i check the State of the Variable (Undefinded, Update, Insert).
Basically a
Case StateVariable Of
Case Update: CallUpdateSQLStatement;
Case Insert: CallInsertSQLStatement;
Case Undefined: ShowMessage('Ooops');
End;
Done