There are diffrent approaches in sql to do this. Triggers, output clause or the the parameter value can be determined if it will save to your deleted messages tables.
If you are using access, here is the sample code in sql with minimal conversion to access code. Just convert it. 🙂
if action = 1
begin
update masterunit
set deletedrecord = 1
insert into deletereason (reason)
values ("your reason")
end