How to protect controls after entering

shevada123

New member
Local time
Today, 09:02
Joined
Apr 24, 2007
Messages
9
I have a database and I have to enter claim information which consists of claim number, customer name, tires submitted, Supplier and so on.

I've noticed that when others are using the form they have mistakenly typed over some of the data on a specific record; altering the data.

How can I protect certain fields such as customer name and customer name, claim number on the form so that these cannot be edited by mistake.

I appreciate your help in advance...

:confused: and :eek:
 
If Me.NewRecord=True Then
Me![ControlName].Locked=false
Else
Me![ControlName].Locked=True
End If

Or you can do it if there is data in the control
If IsNull(Me![ControlName]) Then
Unlock It
Else
Lock It
End If

You can use these in the onenter

Mick
 
If you do this in the OnEnter event, the user won't be able to correct a mistake even while they're inputing the original data. The proper place for this kind of code is in the Form_Current sub:

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

You should, of course, have some strategy in mind for when data needs to be changed! Either an admin person who can go directly to the table and edit it, or a button on the form that allows users to unlock the field(s) for editing, after making a conscious decision to do so.

Linq
 
Protecting controls

If I choose to allow users to unlock the form to make edits.. how do I set that button up?

I am going to try this option.

Thanks for your quick response.. Thanks guys. :D
 
Place a command button on the form, name it AllowEditsButton and use this code:

Code:
Private Sub AllowEditsButton_Click()
  Me.YourField.Locked = False
End Sub

The code I've already given you, in the Form_Current event, will take care of locking the field again when you move to another record.

Linq
 
Thank You Sooooo Much!!!

It worked like a charm!!!

Thanks guys... :D:o
 

Users who are viewing this thread

Back
Top Bottom