Locking a record from futher changes

D

Dan

How can I lock a record after someone changes it in a form so that no more
changes can be made to that record. I have a database that tracks items as
either being in stock or out of stock. When we do inventory I would like to
lock a record so that it can not be change back in my form. So when I'm
doing inventory and an item is out of stock and a clerk clicks on the out of
stock button that record is locked and someone can not accidently go in
change it back. The only way I would like it to changed it was that I would
have to go into the table myself and change it or I create another form that
when the item comes in the person inventoring it will use this form to change
the item from out of stock to in stock.
 
K

Ken Snell \(MVP\)

You can use the Current event of a form to test for the condition of whether
the record should be locked or not. You could add a field to your table that
holds a value to show whether the record should be locked or not, and then
test that value in the form's Current event to decide if the form's
AllowEdits property should be set to False or not.

Private Sub Form_Current()
Ne.AllowEdits = (Me.NameOfLockedRecordField.Value = False)
End Sub

Then use the button of which you wrote to set the value of this new field.
You'd need a way to change the value back to "unlocked" setting, too.
 

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

Similar Threads


Top