I want to lock a field after Update

  • Thread starter Thread starter debbie
  • Start date Start date
D

debbie

I have a form that automaticly puts a date stamp in when clicked on. I want
to lock it after the first date stamp so that the date can not change but
everything I have done either locks or unlocks it. Can someone help?
 
Didn't work got an error. Let me explain in more detail. I am creating a
Document Tracking System. I am not really good at
coding so I have a macro that imputs now() when clicked in this is a date
received box on a subform that has multipul people listed for reveiwing the
document for content and a different subform for peple reviewing it for
technical Correctness I want to make it so that date received can not be
changed once they click in the received box. I
also have an approved or declined check box and when one of those is clicked
it adds the Now() date to the form in another field Date Approved/Declined.
I want to lock both of these also when either approved or declined is
clicked on the date in the date approved or declined can not be changed. I
hope you understand what I am trying to say.


Thank you so much for your help.
 
What error did you get? It would be helpful to know that. The only thing I
see that could cause the error is the name of the control. Since I don't
know what your control name is, I made one up.

The NewRecord Property is to know if the current record is a new record or
not. If it is a new record, then the code above should unlock the controls.
When you navigate to an existing record, it should lock the controls.

Also, are you using date and time for you data? If you don't need the time,
you could use just Date, Now returns data and time.
 
Tried it again it didn't give me an error but it didn't work. I am still
locked out to the field. I guess because the record is not new. Who ever
initiates the correspondence actually chooses the Approvers. What if I use
somesort of Not Null on the actual fields? Do you think that would work.
 
Sorry Forgot to put in the Code

Private Sub Date_Received_Click()

If Me.Date_Received = IsMissing Then
Me.Date_Received = Now()

If .Date_Received = Not IsMissing Then
Date_Received.Locked
End
End Sub
 
First, IsMissing is used for checking arguments for a sub or function,
second, the syntax is incorrect. Try

If IsNull(Me.Date_Received) Then
Me.Date_Received = Now()
Else
Me.Date_Received.Locked = True
End If
 
Back
Top