Locking Specific Records

AceBK

Registered User.
Local time
Today, 10:58
Joined
Dec 2, 2011
Messages
75
Hello, I have done a fair bit of research on the forum in regards to locking specific records. I have tried the
If checkbox = true then
me.allowedits = false
Else
me.allowedits = true
End If.

I have also tried
Me.AllowEdits = Switch(Me.Lockrecord, False, True, True)

The problems I am running into are:
1. When I open the form and the checkbox is checked, the records are unlocked until I uncheck and recheck the checkbox and hit refresh. They are not locked when I first open the form. I put this code in the 'AfterUpdate' event of the checkbox and the
2. When one of the records has the checkbox checked, all of the records are locked, not just the one that has the checkbox checked. I have made a button to unlock the records, but that unlocks all of them. The challenge I see is that I have multiple users so I don't want one user to unlock all the records and the other users have access to them.

I am using Access 2010. The form name is 'Order Form' and the checkbox name is Lockrecord. If you can please help me with this or point me in some direction, I would greatly appreciate it.

I have just starting using this forum for about a month and am very excited about the help that one can glean from here.
Thank you, AceBK
 
Have you tried putting your code in the current event of the form as well as the after update event of the checkbox? That will set it as the form opens and when the user changes records.
 
Well, that worked, on my computer. One of the other users has a message saying that they can't run the VBA code. Says something about deleting the code from my project. Any idea why it would work on my computer, but not this other person's?
 
The DB is split with their own Front End access.
 
That message about "deleting code from your project" is suspiciously like the problem with Windows 7 SP1 and Office 2010 SP1 which did some registry changes to the ActiveX Data Objects (ADO) and it sounds like you both are not on the same version of Windows and/or not on the same service pack level of Office.
 
A really simple way to lock records under these circumstances is to use Conditional Formatting. Unlike the code to set the AllowEdits property (or the Locked property on the controls) it also works on Continuous Forms.

Set the criteria for the Conditional Format of one of the controls to:
Expression Is | Not checkboxfieldname
and tick the Enabled checkbox in the Format.

Copy this control to the clipboard and Paste Formatting onto the others.

BTW There is not need to test a Boolean value against True or False.
The Boolean is already True or False so instead of:
Code:
If MyBooleanField = True Then
simply write:
Code:
If MyBooleanField Then
 
Wow, thank you all for your responses, it has helped a ton. In regards to the VB project code, I save the front end as an ACCDE file and the code didn't work. When I save the front end as ACCDB file it worked. Any idea why that might be?
 
2. When one of the records has the checkbox checked, all of the records are locked, not just the one that has the checkbox checked. I have made a button to unlock the records, but that unlocks all of them. The challenge I see is that I have multiple users so I don't want one user to unlock all the records and the other users have access to them.
Sounds very much like an unbound checkbox in a Continuous form.
 
Sounds very much like an unbound checkbox in a Continuous form.

Really? OP said it was solved by code in the current event, as suggested. Did we not read the thread? ;)

AceBK: Specific code doesn't work, or any code at all? Was Bob's suggestion of checking versions addressed?
 

Users who are viewing this thread

Back
Top Bottom