Prevent user from coincidence delete or edit records

Sokkheng

Member
Local time
Tomorrow, 06:36
Joined
Jul 12, 2023
Messages
40
I want to prevent user from coincidence delete or edit record in the Main invoice form and Sub invoice form, and I have one command button that allow Edit or Delete when i click.
I set in the form property of Main invoice form (Main invoice form have one Sub invoice form in side):
Allow editions = No
Allow Deletions = No
the results are:
1- When i open the invoice form it still can edit or delete and i click on sub invoice form is lock mean it lock only sub invoice form then i click back on main invoice form it back to lock also. mean the first open main invoice form don't lock until i click on sub invoice form and back to click on main invoice form it change to lock also.
2-When we add new record, we can add only main invoice form other way sub invoice form is inactive can't add new record.
Please let me know what problems in my form and how can i fix it?
Thanks for any help.
 
Try also setting Allow Edits = No and Allow Deletions = No on your subform. Also, you could set the Locked = Yes or Enabled = No on your subform control on the main form.
 
It is almost always more complicated and requires code in more events to control ahead of time whether the record is updatable or not. Sometimes, the path of least resistance is to use the form and subform's BeforeUpdate event and OnDeleteConfirm events to stop the edit or stop the delete if the user tries to do it without first requesting permission.
 
how can i fix it?
It may also be good practice to generally lock these forms for editing, appending, and deleting. Nothing can happen anymore without all the code.

Separate forms can be used for desired editing, appending and deleting, which can be called up from the display form. These separate forms may well be additional instances of the existing forms.
 
One of the reasons I use the "catch" method to stop updates/deletes rather than the "prevent" method is because setting AllowEdits to No prevents the user from using certain types of search features because it locks all controls except buttons. If you understand how BeforeInsert, BeforeUpdate, and onDeleteConfirm work, you have no trouble stopping unwanted or invalid updates. You should have validation code in all those events already. You can add an additional section to check security or if you use the toggle button method, to check if the user pressed the button to toggle to "update" mode.

I never create separate forms for add/change/delete/view. I use a single form. That means I don't need to "duplicate" code in multiple places.
 

Users who are viewing this thread

Back
Top Bottom