How to update/cancel changes and Lock individual records? (1 Viewer)

amb3r

Registered User.
Local time
Today, 03:31
Joined
Jul 10, 2006
Messages
44
I have a database/form with thousands of employee records, which will be used by a number of novice users to update/edit and lock records. I want to improve the form to make it easier for them to use. There are two main issues I am having difficulties in:

1)Many of my users have difficulties with saving/cancelling changes to records. E.g. sometimes users amend about 15/20 fields but then realise they have entered incorrect data for that record! At the moment I don’t have an option to cancel changes.

I have added two command buttons ("update" and "cancel") on my form. This should make it easier for users; giving them the option to either update or cancel changes for the current record. However, I am having difficulty in writing the code for this – the “update” button should have code to save changes and the “cancel” button should have code to discard changes
I would be very grateful if anyone could “help/Guide” me with the code for this plzzz.

2) I also want to have an option to lock a particular record (i.e. if an employee leaves, I want to lock their record so that the data can only be viewed but no further changes can be made to it. I know how to lock fields - but that will lock the fields for all records! I want to have an option to only lock certain records. I think I need a tick box on my form to achieve this. But again, unfortunately, I’m having difficult of writing the code for this! :(

Once again, any feedback would be greatly appreciated.

Thanks a lot,
Kind regards,
Amber
 

RuralGuy

AWF VIP
Local time
Today, 04:31
Joined
Jul 2, 2005
Messages
13,826
To "Update"
If Me.Dirty Then
DoCmd.RunCommand acCmdSaveRecord
End If
To "Cancel"
Me.UnDo
 

amb3r

Registered User.
Local time
Today, 03:31
Joined
Jul 10, 2006
Messages
44
Excellent!
Thanks alot RG. you're a star!

Does anyone know the answer to the second point above(locking only certain records via a tick box, command button etc)?

Cheers,

Amber
 

amb3r

Registered User.
Local time
Today, 03:31
Joined
Jul 10, 2006
Messages
44
thanks for that RG. I shall have a read through that. Cheers
 

fionahl

Registered User.
Local time
Today, 20:31
Joined
Jun 25, 2009
Messages
11
Hi all, I realise this is an old thread, but if anyone can help, it would be greatly appreciated.

I have a db for which I used the above code from Rural Guy (code written by Allen Browne), which works great for locking and unlocking the database to prevent accidental changes. I also like the idea of having the red box to indicate that it is locked.

My issue is this:
When the db is locked, I can still click my "Add new record" button, and then I get the new record, but with no subforms (so it looks like blank pages). Similarly, when the db is unlocked, I click "Add new record", add some data, then click "Lock", I get:

Error 2455 - You entered an expression that has an invalid reference to the property Form/Report

However the database still locks.

Are any of you able to shed some light on this?
 

MyTech

Access VBA
Local time
Today, 06:31
Joined
Jun 10, 2010
Messages
108
Thank you AMB and RG for the Q&A #1, it helped for me now.

Sometimes your doings have a far effect after years... ;)
 

RuralGuy

AWF VIP
Local time
Today, 04:31
Joined
Jul 2, 2005
Messages
13,826
We aim to please. :D Thanks for the kind words.
 

bg3075

Registered User.
Local time
Today, 05:31
Joined
Mar 20, 2009
Messages
43
We are tracking the record creations and edits by user, but is there a way to be alerted when someone deletes a record in an Access table?
 

Users who are viewing this thread

Top Bottom