Help with an If statement to lock a field.

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

debbie

Can someone help me fix this 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


Would Mucho Appreciate it.

Debbie
 
You can try:

If me.Date_Received = Null Then
Me.Date_Received = Now()
Me.Date_Received.Locked = True
Else
me.Date_Received.Locked = True

End If


You can also use the Nz function, to verify at runtime, and set the
lock position that way as well

Nz([Me.Date_Received],Now())

Just some examples.
 
Apologies, I should also add, is the user clicking on this specific
field? If not then the click event will not fire. If this is just a
simple text box, you may want place it on the form's current event.
That way each time a user goes to a new record this validation can take
place.
 
Actually it would be when the get in the field whether by clicking or
tabbing so should it be on focus?
 
Oh, My God this is going to drive me to drink. LOL
I tried putting the code in it locks me out of the field but it doesn't put
the date in which is what I need it to do. I have to focus it on a form
because there are a list of people on a subform that will need to click on
or tab into the field.
 
Let's remove the Locked Features for the moment to make sure we are
getting the appropriate data into the field. Comment out the Locked
properties to see if the value populates with the Now Value
 
Back
Top