Locked controls in a form

T

Tony Williams

I have a datasheet form, that is on a tabcontrol, that has 3 controls
ActionDate (Default value is Date())and ActionTime Default value is Time())
and Action Log (which is a text box). All the controls have their their
locked property set to Yes. I also have this code in the OnCurrent Event of
the form:
Private Sub Form_Current()
If Me.NewRecord Then
Me.Action_Date.Locked = False
Else
Me.Action_Date.Locked = True
End If
If Me.NewRecord Then
Me.Action_Time = False
Else
Me.Action_Time.Locked = True
End If
If Me.NewRecord Then
Me.Action_Log.Locked = False
Else
Me.Action_Log.Locked = True
End If
End Sub

When the form opens the date and time are present. However as soon as I
start to type into the text box which is the Action Log control the time
reverts to 00:00:00. The date stays as it should ie todays date.
Does anyone know why this is happening?
Thanks
Tony
 
O

OldPro

I have a datasheet form, that is on a tabcontrol, that has 3 controls
ActionDate (Default value is Date())and ActionTime Default value is Time())
and Action Log (which is a text box). All the controls have their their
locked property set to Yes. I also have this code in the OnCurrent Event of
the form:
Private Sub Form_Current()
If Me.NewRecord Then
Me.Action_Date.Locked = False
Else
Me.Action_Date.Locked = True
End If
If Me.NewRecord Then
Me.Action_Time = False
Else
Me.Action_Time.Locked = True
End If
If Me.NewRecord Then
Me.Action_Log.Locked = False
Else
Me.Action_Log.Locked = True
End If
End Sub

When the form opens the date and time are present. However as soon as I
start to type into the text box which is the Action Log control the time
reverts to 00:00:00. The date stays as it should ie todays date.
Does anyone know why this is happening?
Thanks
Tony

Did you mean to write this:
Me.Action_Time = False
or this?
Me.Action_Time.Locked = False
 
T

Tony Williams

Thanks I've been staring at that for about an hour and never spotted it???
Time for a break I think
Cheers
tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top