Write protection

John liem

Registered User.
Local time
Today, 03:16
Joined
Jul 15, 2002
Messages
112
How can I write-protect a record in a "input from" from overwriting after this field / record has been input. So, if this field is not empty, protect it from overwriting ... and if empty, allow man to record a data into this field. Thanks in advance
 
On the AfterUpdate() event of the control you could set the focus to another control and then use the Enabled and Locked properties of the control you wish to protect.
 
Hi Mile,

I am just a beginner, can you show me how to write the procedure?
 
Basically, right click on your control in Design View and select properties.

Find the events tab and select the AfterUpdate, click on the button that appears with the three dots.

Welcome to the code screen.

Between the lines you'll first need to set the focus to another control, so put:

txtYourNextControl.SetFocus

Next, we'll lock the current control

Code:
With txtYourControl
   .Enabled = False
   .Locked = True
End With

This will lock it.

So, you should have:

Code:
Private Sub txtYourControl_AfterUpdate()
   txtYourNextControl.SetFocus
   With txtYourControl
      .Enabled = False
      .Locked = True
   End With   
End Sub

Remember to change the control name's I've put to match those in your database.

Next time you run you should find that the control will be locked after data entry.
 

Users who are viewing this thread

Back
Top Bottom