paul.coshott Posted April 23, 2019 Share Posted April 23, 2019 procedure TfStaffMnt.btnDeleteClick(Sender: TObject); procedure mbDeleteStaff(Sender: TComponent; Res: Integer); begin //code here to delete the staff record qStaffDelete.ParamByName('pStaffId').AsInteger := qStaff.FieldByName('pStaffId').AsInteger qStaffDelete.ExecSQL; end; begin MessageDlg('Delete the selected staff member?', mtConfirmation, mbYesNo, mbDeleteStaff); end; I find this code much neater and easier to maintain. Any way this can be done? Cheers, Paul Quote Link to comment Share on other sites More sharing options...
paul.coshott Posted May 10, 2019 Author Share Posted May 10, 2019 Anyone have any idea regarding this question? Quote Link to comment Share on other sites More sharing options...
Pep Posted May 10, 2019 Share Posted May 10, 2019 Hello Paul, In Delphi 10.2, the Callback procedure "mbDeleteStaff" does'nt compile if is defined inside another procedure / function. You can use an anonymous procedure: MessageDlg('Delete the selected staff member?', mtConfirmation, mbYesNo, procedure(Sender: TComponent; Res: Integer) begin // code here to delete the staff record if Res = mrOk then begin qStaffDelete.ParamByName('pStaffId').AsInteger := qStaff.FieldByName('pStaffId').AsInteger qStaffDelete.ExecSQL; end; end ); Quote Link to comment Share on other sites More sharing options...
paul.coshott Posted May 10, 2019 Author Share Posted May 10, 2019 Hi Pep, Thanks, that'll work nicely! Cheers, Paul Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.