Question Is it possible to "Lock" archived records?

wchelly

Registered User.
Local time
Today, 09:03
Joined
Mar 1, 2010
Messages
146
I want to lock archive records so that they can't be edited, however I want them available to users for viewing. So for example if the file is "closed" the record can not be changed.
 
If you are flagging them as archieved using say a Check box you could use some code along the lines of the following in the form's On Current event;
Code:
Me.AllowEdits = Not Me.YourCheckBox
This will work because the check box will return True when checked and False when unchecked and the Not operator will reverse that status, so any record flagged as archived will have a Checked check box and will therefore not be able to be edited.
 
I tried this on the Main form and That works! But I have one issue. My "archived" checkbox is in a "subform" (And related table).

So I tried
Me.AllowEdits = Not Me.[TableName].YourCheckBox

Me.Allow Edits = Not Me.[Shipment_Details].Closed

And this works to the extent that it doesn't let me edit anything on the form. But it doesn't let me do anything with the records that are NOT closed either. Any thoughts on why that might be.
 
Are you putting that code in your main form or your subform where you may have archived records? It should either be in the subform or you need to change the code to affect the subform. To do things in a subform from VBA in the main form, your syntax would look like:
Me.subControlName.Form.AllowEdits
 
Given that the check box is on a Sub Form check this link for the correct syntax for referring to it.

Code:
Me.AllowEdits = Not Me!Subform1.Form!ControlName

and to lock the sub form

Code:
Me!Subform1.Form.AllowEdits = Not Me!Subform1.Form!ControlName
 
That link was very helpful!

Here is what I found to work in the end.

Private Sub Form_Current()
If Shipment_DetailsA.Form!Closed = True Then
Me.AllowEdits = False
Else
Me.AllowEdits = True
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom