Time Card , Disabling Control once data is entered

%3CLINGO-SUB%20id%3D%22lingo-sub-1041363%22%20slang%3D%22en-US%22%3ETime%20Card%20%2C%20Disabling%20Control%20once%20data%20is%20entered%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1041363%22%20slang%3D%22en-US%22%3EDear%20Sirs%2C%3CBR%20%2F%3EI%20am%20doing%20a%20dB%20in%20MS%20Access%2C%20the%20purpose%20of%20it%20is%20to%20record%20times%20of%20employee%20(something%20on%20the%20lines%20of%20Time%20Card)..%3CBR%20%2F%3EI%20have%20TimeIn%2C%20TimeOut%20and%20Lunchtime%20in%20and%20Lunchtime%20Out%3CBR%20%2F%3EAnd%20some%20employee%20info%20to%20go%20with..%3CBR%20%2F%3EI%20have%204%20buttons%20for%20each%20timing%2C%20i.e.%20when%20I%20press%20button%20current%20time%20is%20passed%20to%20the%20time%20boxes%20(fields)%20the%20code%20on%20click%20of%20button%20is%20as%20under%3A%3CBR%20%2F%3EMe.timein%20%3D%20now()%3CBR%20%2F%3ENow%2C%20the%20problem%20I%20am%20facing%20here%20is%20I%20am%20trying%20to%20lock%20the%20field%20after%20the%20value%20is%20passed%20to%20it%2C%20in%20this%20case%20on%20click%20of%20button.%20I%20have%20tried%20the%20following%20code%20on%20afterupdate%20property%20of%20field%20and%20I%20also%20put%20the%20same%20code%20oncurrent%20property%20of%20form%2C%20but%20it%20doesn't%20work...%3CBR%20%2F%3E%3CBR%20%2F%3EPrivate%20Sub%20Form_Current()%3CBR%20%2F%3EIf%20Len(Me.%5BtimTimeIn%5D%20%26amp%3B%20%22%20%22)%20%26gt%3B%200%20Then%3CBR%20%2F%3EMe.%5BtimTimeIn%5D.Enabled%20%3D%20False%3CBR%20%2F%3EMe.%5BtimTimeIn%5D.Locked%20%3D%20True%3CBR%20%2F%3EElse%3CBR%20%2F%3EMe.%5BtimTimeIn%5D.Enabled%20%3D%20True%3CBR%20%2F%3EMe.%5BtimTimeIn%5D.Locked%20%3D%20False%3CBR%20%2F%3EEnd%20If%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3EPrivate%20Sub%20timTimeIn_AfterUpdate()%3CBR%20%2F%3EIf%20Len(Me.%5BtimTimeIn%5D%20%26amp%3B%20%22%20%22)%20%26gt%3B%200%20Then%3CBR%20%2F%3EMe.%5BtimTimeIn%5D.Enabled%20%3D%20False%3CBR%20%2F%3EMe.%5BtimTimeIn%5D.Locked%20%3D%20True%3CBR%20%2F%3EElse%3CBR%20%2F%3EMe.%5BtimTimeIn%5D.Enabled%20%3D%20True%3CBR%20%2F%3EMe.%5BtimTimeIn%5D.Locked%20%3D%20False%3CBR%20%2F%3EEnd%20If%3CBR%20%2F%3EEnd%20Sub%3CBR%20%2F%3E%3CBR%20%2F%3EAnd%20I%20am%20using%20following%20codes%20on%20click%20of%20buttons%20to%20pass%20current%20times%3CBR%20%2F%3E%3CBR%20%2F%3EPrivate%20Sub%20cmdTimeIn_Click()%3CBR%20%2F%3EMe.timTimeIn%20%3D%20Now()%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3CBR%20%2F%3E%3CBR%20%2F%3EPrivate%20Sub%20cmdTimeInLunch_Click()%3CBR%20%2F%3EMe.timTimeOutLunch%20%3D%20Now()%3CBR%20%2F%3EEnd%20Sub%3CBR%20%2F%3E%3CBR%20%2F%3EPrivate%20Sub%20cmdTimeOutLunch_Click()%3CBR%20%2F%3EMe.timTimeInLunch%20%3D%20Now()%3CBR%20%2F%3EEnd%20Sub%3CBR%20%2F%3E%3CBR%20%2F%3EPrivate%20Sub%20cmdTimeOutShift_Click()%3CBR%20%2F%3EMe.timTimeOut%20%3D%20Now()%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3CBR%20%2F%3E%3CBR%20%2F%3EI%20have%20attached%20an%20image%20of%20my%20form%2C%20hope%20it%20is%20attached%20properly.%3CBR%20%2F%3EPlease%20help.%3CBR%20%2F%3E%3CBR%20%2F%3ERegards.%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1041363%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAccess%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Occasional Contributor
Dear Sirs,
I am doing a dB in MS Access, the purpose of it is to record times of employee (something on the lines of Time Card)..
I have TimeIn, TimeOut and Lunchtime in and Lunchtime Out
And some employee info to go with..
I have 4 buttons for each timing, i.e. when I press button current time is passed to the time boxes (fields) the code on click of button is as under:
Me.timein = now()
Now, the problem I am facing here is I am trying to lock the field after the value is passed to it, in this case on click of button. I have tried the following code on afterupdate property of field and I also put the same code oncurrent property of form, but it doesn't work...

Private Sub Form_Current()
If Len(Me.[timTimeIn] & " ") > 0 Then
Me.[timTimeIn].Enabled = False
Me.[timTimeIn].Locked = True
Else
Me.[timTimeIn].Enabled = True
Me.[timTimeIn].Locked = False
End If

End Sub


Private Sub timTimeIn_AfterUpdate()
If Len(Me.[timTimeIn] & " ") > 0 Then
Me.[timTimeIn].Enabled = False
Me.[timTimeIn].Locked = True
Else
Me.[timTimeIn].Enabled = True
Me.[timTimeIn].Locked = False
End If
End Sub

And I am using following codes on click of buttons to pass current times

Private Sub cmdTimeIn_Click()
Me.timTimeIn = Now()

End Sub

Private Sub cmdTimeInLunch_Click()
Me.timTimeOutLunch = Now()
End Sub

Private Sub cmdTimeOutLunch_Click()
Me.timTimeInLunch = Now()
End Sub

Private Sub cmdTimeOutShift_Click()
Me.timTimeOut = Now()

End Sub

I have attached an image of my form, hope it is attached properly.
Please help.

Regards.
0 Replies