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!

Locking fields 2

Status
Not open for further replies.

kpryan

Technical User
Aug 24, 2005
282
US
Hi all,
On a form I have some fields that I want to lock with a check box. If the data has to be changed then the check box can be unmarked.
How would I do this.

many thanks,

ken
 
Howdy kpryan . . .

There's an [purple]ambiguity[/purple] here you need to consider.
TheAceMan said:
[blue]You can't lock a control thats [purple]in edit mode![/purple] . . . an error will be raised![/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
You can't lock a control thats in edit mode! . . . an error will be raised!

Sorry, Aceman, I don't understand your quote. When, exactly, is a control in "edit mode?" This code should do what the OP wants, unless I've misinterpreted his post.

Code:
Private Sub Form_Current()
If MyCheckBox Then
  Me.MyTextBox.Locked = True
Else
  Me.MyTextBox.Locked = False
End If
End Sub

Code:
Private Sub MyCheckBox_AfterUpdate()
If MyCheckBox Then
  Me.MyTextBox.Locked = True
Else
  Me.MyTextBox.Locked = False
End If
End Sub

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Thanks The Missinglinq,
Thats what I needed. Sorry The Aceman1. What I wanted was to be able to lock a field once data has been entered to stop idiot staff from removing it...
I tried the code and it works great.

Ken
 
missinglinq said:
[blue]When, exactly, is a control in "edit mode?[/blue]
When you enter the 1st character! This triggers the [blue]OldValue[/blue] property as well as causing the record to enter edit mode (depicted by the pencil icon) if its the 1st character entered in the record.

kpryan said:
[blue] . . . What I wanted was to be able to lock a field once data has been entered to stop idiot staff from removing it...[/blue]
I wasn't sure if you intended to lock fields while editing! I did say it was something to consider! However your locking after data entry, which is fine.

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top