Solved How to prevent the deletion of columns in subform by users?

yunhsuan

Member
Local time
Today, 19:08
Joined
Sep 10, 2021
Messages
54
Hello!

The column in subform can be easily deleted by selecting the whole column and click "delete" key in Datasheet view. This means users may delete colunms in subform accidentally. How to prevent this from happening?

Thanks in advance!
 
Open the subform in design mode, click on the properties, look for allow deletion, pick No
 
Hello!

The column in subform can be easily deleted by selecting the whole column and click "delete" key in Datasheet view. This means users may delete colunms in subform accidentally. How to prevent this from happening?

Thanks in advance!
Users won't be able to do that if you give them an ACCDE version of the db.
 
hi @yunhsuan, another consideration is that they can't do it for anyone but themself (maybe they don't want to see it) if the database is SPLIT into front-end and back-end, as it should be for multiple users ...

If they mess up their front-end and want the column back again, you could just give the front-end to them again

If there are columns you don't want them changing or removing, you can lock them (user can select but not change) and/or disable them so they show but the user can't even select it.
 
If you do proper validation in the form's BeforeUpdate event, you can prevent a record from being updated/added if it violates your validation rules.

So, if the field is required, you should do two things.
1. Set it to be required on the table and if the field is text, set its AllowZeroLengthStrings property to No
2. Add validation in the FORM's BeforeUpdate event to ensure that it is not null so you can give the user a friendly error message.


Code:
If Me.SomeField & "" = "" Then
    Msgbox "SomeField is Required.", VBOKOnly
    Cancel = True
    Me.SomeField.SetFocus
    Exit Sub
End If
 
On page load event of the form add this code
Code:
With frm
 .AllowAdditions = False
 .AllowDeletions = False
 .AllowEdits = False
 End With
 
@yunhsuan, glad that works for you. The database should still be split into front-end and back-end so each user isn't sharing a copy of the front-end. Perhaps you're doing that already, but I got the idea that you're not ...
 
Open the subform in design mode, click on the properties, look for allow deletion, pick No
That only prevents users from deleting records

@yunhsuan Other option is to use a continuous form rather than a datasheet
 
Using .accde does not prevent user from removing values from a field. accde does prevent all design options and many that are technically not design options but are controlled by control menus. You STILL need proper validation code.
 

Users who are viewing this thread

Back
Top Bottom