Locking a Record

bsnalex

Registered User.
Local time
Today, 15:44
Joined
Feb 27, 2009
Messages
27
Hi, first post, hopefully someone can help me.

I'm building a database to audit the use of "Do Not Resuscitate" forms at the hospital I work at. To capture the use of each DNR, I've got a form to enter a series of Yes/No questions for each patient. What I want to do is, to ensure that noone changes the data after it's been input, I want to "lock" the completed record on the table that the form references. is there a way to set this upon completion of a record?

-Access 2002 (10.6771.6839) SP3
 
You can use the "Record Lock" property in the form properties window to lock the records
 
You will need an additional field in your table, a yes/no field would do the trick nicely, that gets changed once the user is happy that the data entered is correct. You would need change this field behind the scenes once the user has finished entering data, and possibly confirm that they have in fact finished with the record.

You would then need some code in the On Current event of the form to check that field and either lock the record or not depending on the result. It would look something like;

Code:
If Me.YourLockIndicator.Value = True Then [COLOR="Green"]'Substitute your field name for [B]YourLockIndicator[/B][/COLOR]
     Me.AllowEdits = False
Else
     Me.AllowEdits = True
End If

If you have sub forms you would need additional lines to set AllowEdits accordingly. Follow this link for the correct syntax for referring to sub forms and their properties and controls.
 
You can use the "Record Lock" property in the form properties window to lock the records
Tried that, but I could still edit the fields when I view my saved records via switchboard (I've got two buttons, one to view the saved records, and one to add a new).
 
The problem, I think, is is that you only have two choices when you use the Switchboard Manager to create a button to open a form. You can open the form in in AddMode or EditMode. You'll need to edit your "view records only" button.

First create a simple Macro:
  1. Under "Action" select Open Form
  2. Moving down the Macro grid, enter your form name
  3. Further down you'll see Data Mode; select ReadOnly
  4. Save and name the Macro
Now goto Tools - Database Utilities - Switchboard Manager.
  1. Hit Edit then then move down to the button you use to open the "view records."
  2. Hit Edit again
  3. Under Command select Run Macro
  4. Use the next dropdown to select your new Macro
Your "view records only" form should now open in Read Only.
 

Users who are viewing this thread

Back
Top Bottom