Forum Discussion
Asad_khan1971
Dec 01, 2019Copper Contributor
Time Card , Disabling Control once data is entered
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.
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.
No RepliesBe the first to reply