Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lock records in table after work on records has been done?

Status
Not open for further replies.

MaddiMond

Technical User
Mar 28, 2005
76
US
For weeks I have been trying to find out if there is a way to lock records in a table in the sense that no changes can be made to them anymore. The idea is to make it possible for the user of the database to lock records for a month, once all the calculations on it have been done. I did not find any information in the help or books on it.

Maddi
 
This is not a built-in function for Access. If your users edit records only on forms, you could lock them out of all changes there.
I would suggest adding a 'locked' field to the table, then modifying every form that could possibly edit that record and not allowing it if the locked field is checked.

If, on the other hand, your users may also be accessing this table through an updatable query (or by opening the table itself), I do not know of any way to prevent editing.
good luck.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
You need two things to accomplish this...

First, you need to add a boolean yes/no or true/false field to the table. The boolean field, call it LockRecord, defaults to false, and evetually is set to true. LockRecord would be on the form but hidden.

Second, you need to add a sub routine for the OnCurrent event procedure to your form to lock most of the controls (text boxes, list boxes, combo boxes, subforms).

Something like...

Code:
Dim booLocked as Boolean

booLocked = Me.LockRecord

Me.Text1.Locked = booLocked
Me.List3.Locked = booLocked
Me.Combo4.Locked = booLocked
Me.YourSbForm.Locked = booLocked
'etc

You will have to add the name of your controls to the code.

You will also need a mechanism for "locking" the record. One way would be to have a command button called "cmdLockRecord"

It would set
Me.LockRecord = True

Then, to your OnCurrent event procedure...

Code:
Dim booLocked as Boolean

booLocked = Me.LockRecord

Me.Text1.Locked = booLocked
Me.List3.Locked = booLocked
Me.Combo4.Locked = booLocked
Me.YourSbForm.Locked = booLocked
'etc

Me.cmdLockRecord.Visible = Not booLocked

Richard
 
Hi
Would it be possible to use Allow Edits (Deletions / Additions)? For example:
[tt]If Me!LockedRec Then
Me.AllowEdits = False
Me.frmSubform.Form.AllowEdits = False
End If[/tt]
 
That works except any unbound (i.e. for searching) will not work either.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top