I have a time keeping form that should set properties based on the conditions of the last record such as if there are no time stamps then the time-in field should be enabled and the time-out field should not, but it is not working.
Only the second set of conditions works correctly.
Here is the code:
Only the second set of conditions works correctly.
Here is the code:
Code:
Private Sub Form_Load()
DoCmd.GoToControl "SfrmTimePunch"
DoCmd.GoToRecord , , acLast
If Me!SfrmTimePunch!TimeIn = 0 And Forms!frmTimeClockEmployee!SfrmTimePunch!TimeOut = 0 Then
Me!SfrmTimePunch.Form.DataEntry = True
Me!SfrmTimePunch.Form!TimeIn.Enabled = True
Me!SfrmTimePunch.Form!TimeOut.Enabled = False
Me!SfrmTimePunch.Form!txtWONumber.Enabled = True
Me!SfrmTimePunch.Form!txtWONumber.SetFocus
' Exit Sub
ElseIf Me!SfrmTimePunch!TimeIn > 0 And Forms!frmTimeClockEmployee!SfrmTimePunch!TimeOut > 0 Then
Me!SfrmTimePunch.Form.DataEntry = True
Me!SfrmTimePunch.Form!TimeIn.Enabled = True
Me!SfrmTimePunch.Form!TimeOut.Enabled = False
Me!SfrmTimePunch.Form!txtWONumber.Enabled = True
Me!SfrmTimePunch.Form!txtWONumber.SetFocus
'Exit Sub
ElseIf Forms!frmTimeClockEmployee!SfrmTimePunch!TimeIn > 0 And Forms!frmTimeClockEmployee!SfrmTimePunch!TimeOut = 0 Then
Me!SfrmTimePunch.Form.DataEntry = False
Me!SfrmTimePunch.Form!TimeIn.Enabled = False
Me!SfrmTimePunch.Form!TimeOut.Enabled = True
Me!SfrmTimePunch.Form!txtWONumber.Enabled = False
Me!SfrmTimePunch.Form.TimeOut.SetFocus
End If
End Sub