1 (edited by papafrankc 2022-08-26 06:45:57)

Topic: Prevent a record from being Deleted?

Hi folks,
If I put a record in a table can I make it permanent and prevent the user from deleting it?
.
I have a Supplier table where the user can add and remove suppliers as needed.  But I would like to have one record with the name Unknown so it's always there.
.
It would also be nice when adding a new Equipment record that the Supplier Name shows Unknown shows up automatically, then the user can click on the combo box and choose a different supplier from the supplier table if they want.
.
There will be times where the user will not have a Supplier Name.
However if they leave the field BLANK, then I'm having trouble later on in reports.
-------------------------------------------------
UPDATE:
Here's what I did:
I created a SUPPLIER record with the name = - Unknown -
So when the combo box is sorted this entry comes up at the top of the list.
Then I found DefaultIndex = 0, so I changed it to DefaultIndex = 1
Now when I'm creating a new Equipment record the combo box for SUPPLIER defaults to - Unknown -
This means no more blank combo box fields.  And I can now use this record in reports.
.
So it seems like this technique solves my empty field problem.
However, my first question still remains.  How do I protect this record and not let the user delete it from the SUPPLIER table?
.
Thanks
Frank

2 (edited by pavlenko.vladimir.v 2022-08-26 06:59:29)

Re: Prevent a record from being Deleted?

papafrankc wrote:

Hi folks,
If I put a record in a table can I make it permanent and prevent the user from deleting it?
.
I have a Supplier table where the user can add and remove suppliers as needed.  But I would like to have one record with the name Unknown so it's always there.
.
It would also be nice when adding a new Equipment record that the Supplier Name shows Unknown shows up automatically, then the user can click on the combo box and choose a different supplier from the supplier table if they want.
.
There will be times where the user will not have a Supplier Name.
However if they leave the field BLANK, then I'm having trouble later on in reports.
-------------------------------------------------
UPDATE:
Here's what I did:
I created a SUPPLIER record with the name = - Unknown -
So when the combo box is sorted this entry comes up at the top of the list.
Then I found DefaultIndex = 0, so I changed it to DefaultIndex = 1
Now when I'm creating a new Equipment record the combo box for SUPPLIER defaults to - Unknown -
This means no more blank combo box fields.  And I can now use this record in reports.
.
So it seems like this technique solves my empty field problem.
However, my first question still remains.  How do I protect this record and not let the user delete it from the SUPPLIER table?
.
Thanks
Frank

у кнопки в событии есть  переменная Cancel
Cancel := True; // отменяет действие
в событии OnClick делаете проверку БД
и если запись заблакирована, то используете Cancel
   
the button in the event has a Cancel variable
Cancel := True; // cancels the action
in the OnClick event you do a database check
and if the record is blocked, then use Cancel

Re: Prevent a record from being Deleted?

Hi Frank, Hi Vladimir,
You can take it further and not only prevent the supplier from being deleted, but also prevent it from being edited (which you'd probably want if you're hard-coding - Unknown - into your script (something like the attached)).
I guess it depends how much you trust your users ("trust no one!"  LOL!).
Derek.

Post's attachments

Attachment icon action = cancel.zip 483.75 kb, 124 downloads since 2022-08-26