i have a form contain VBA code
but when i input data to it in exit it save only the last input
anyone can tell me how to solve that problem
the form include three field like this:
employee-id= number (joined with other field -AutoNumber-)
barwar= short-date
hatn= Time
the VBA Code :-
Private Sub employee_ID_AfterUpdate()
Dim NewId As String
Dim strLink As String
NewId = Me.employee_ID.Value
strLink = "[employee ID]=" & NewId
If Me.employee_ID = DLookup("[employee ID]", "hatn_w_roshtn", strLink & " And Format(barwar, ""ddmmyyyy"") = " & Format(Date, "ddmmyyyy")) Then
MsgBox "this Employee_ID is dublicate today"
Me.Undo
ElseIf Time() > TimeValue("7:00:00 AM") And Time() < TimeValue("8:45:00 AM") Then
Me.kati_hatn = Time()
Me.barwar = Date
Else
MsgBox "please go to HR department"
Me.barwar = Date
End If
End Sub
but when i input data to it in exit it save only the last input
anyone can tell me how to solve that problem

the form include three field like this:
employee-id= number (joined with other field -AutoNumber-)
barwar= short-date
hatn= Time
the VBA Code :-
Private Sub employee_ID_AfterUpdate()
Dim NewId As String
Dim strLink As String
NewId = Me.employee_ID.Value
strLink = "[employee ID]=" & NewId
If Me.employee_ID = DLookup("[employee ID]", "hatn_w_roshtn", strLink & " And Format(barwar, ""ddmmyyyy"") = " & Format(Date, "ddmmyyyy")) Then
MsgBox "this Employee_ID is dublicate today"
Me.Undo
ElseIf Time() > TimeValue("7:00:00 AM") And Time() < TimeValue("8:45:00 AM") Then
Me.kati_hatn = Time()
Me.barwar = Date
Else
MsgBox "please go to HR department"
Me.barwar = Date
End If
End Sub
Last edited: