Lock Note field manually

Slab_Rankle

Registered User.
Local time
Today, 19:24
Joined
Aug 10, 2011
Messages
36
Hey guys,

I currently have a Note box on one of my subforms that locks after something has been entered and the user has clicked out of the box. Now, this worked at first, but one user has been trying to copy and paste information from some of the other tabs and when she leaves the current tab the box locks and she can't enter any information. Now, the code I currently have is as follows:

Private Sub Form_AfterUpdate()

If IsNull(Me.Narrative) Then
Me.Narrative.Locked = False
Else
Me.Narrative.Locked = True
End If

End Sub

Private Sub Form_Current()

If IsNull(Me.Narrative) Then
Me.Narrative.Locked = False
Else
Me.Narrative.Locked = True
End If

End Sub

How would I change this so that when a button is clicked the box becomes locked manually? Although it kind of defeats the purpose of locking a box so no one can edit it, it's something I've been asked to put in. Unless there's another option does anyone have any ideas? Any help would be ace :).
 
If you create a command button asn put your Lock code behidn it that will work.

However, a couple of other points

Instead of
Code:
 If IsNull(Me.Narrative) Then
I would use

Code:
 If len(Me.Narrative.value & "") = 0 then

This way you won't get confused between an initially Null field on New Record as opposed to a blank field where data has been deleted.


Secondly you could put a password behind the Cooman Button that would only allow a key use to unlock the field. A simple InputBox within an IF statement should do the trick. Just hard code in the Password or hide it somewhere in a table and use DLOOKUP.
 
Hmmm, well, I've taken out the code I put above (which was on the AfterUpdate and OnCurrent), created a button and set the code on the OnClick to:

If Len(Me.Narrative.Value & "") = 0 Then
Me.Narrative.Locked = False
Else
Me.Narrative.Locked = True
End If

However, now I can't type anything into the notes box. I've deleted the code I posted in my previous post from the AfterUpdate and OnCurrent events so I don't see why it's not letting me type anything...

EDIT: I figured out why nothing was typing, the box had been set to 'Lock' on the property sheet. However, the code I put in place doesn't seem to lock the narrative box when I click the Lock button.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom