How to lock record edits on a subform using a checkbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to be able to lock records for editing in a subform by using a
checkbox, i.e. when the checkbox is unchecked the current record on the
subform can still be edited, when the checkbox is checked the record can only
be viewed, not edited. I would also like to attach some kind of password
control to the checkbox to prevent users from unchecking the chkbox to amend
data.
 
Debra,
Add a new field to the table for your subform (ex. chkLocked -
True/False), and place it your subform.
On the AfterUpdate event of chkLocked use this code...
If chkLocked = True then
Me.AllowEdits = False
Me.AllowDeletions = False
Else
Me.AllowEdits = True
Me.AllowDeletions = True
End If
*Use this same code on the OnCurrent event of the subform record.

That should do it...
 
Al,

I use a similar checkbox for completed jobs to prevent users from
inadvertently changing data once the record should be "finalized" - however,
if someone checks that box by mistake, then I would have to go back in to
the table to reset it. I got around this by adding a new button which is the
only enabled control on the form, which is visible only if the checkbox =
true, and then having a confirmation dialog box ("Are you SURE you want to
change the status of this job?"

This works fine in my app, but Debra wanted to allow this via security - how
would one set that up? (Assuming, of course, that you already have Access
Security enabled)

TIA,

SusanV
 
Al and Susan, Thanks for all your help, I've copied the code and it works a
treat! cheers! debs
 
Susan,
Sorry I missed your post until now...
Well, I don't think Debra meant using the Access security system... just
a simple "password" type check (key users would have this password) before
allowing the chk update. That password would remove the AllowEdits = No.
If you wanted to use Access security, a simple method would be to create
a pop-up form to check uncheck the checkbox. That form could be secured in
Access security to only those users allowed to do so.
 
Thanks for replying Al - after I sent my response I realized that's what I
would nee to do - check user then if user is allowed, open the popup I have
now to change the checkbox, if user is not allowed, popup a insufficient
rights dialog.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top