:confused only the last input saved?:

hardyise

Registered User.
Local time
Today, 18:11
Joined
May 26, 2016
Messages
15
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
 
Last edited:
If you key the table then you CAN'T enter duplicate records, and not need any of this code.
 
first of all thanks for reply Ranman256

the whole database contain duplicate record but per day don't allow duplicate record

my database create for upsend employee
this code prevent employee-id used twice per day
for example if employee_ID=123 and today is 13/07/2016
this ID only allowed used this employee_ID one time
but for next day again that employee can used it again one time
 

Users who are viewing this thread

Back
Top Bottom