electricjelly
Registered User.
- Local time
- Today, 12:27
- Joined
- Apr 3, 2014
- Messages
- 26
Hello,
I would like to make it so that if that last record inputted with the same ID was inputted within the past 5 minutes then it will not input the new record into the database. Im not sure how to code that time frame, but more importantly how to tell access to not do anything if the criteria does not match.
here is my code:
Thank you for any help in my dilemma.
I would like to make it so that if that last record inputted with the same ID was inputted within the past 5 minutes then it will not input the new record into the database. Im not sure how to code that time frame, but more importantly how to tell access to not do anything if the criteria does not match.
here is my code:
Code:
Dim LrecID As Variant
Dim LrecInOUT As Variant
Dim LrecDate As Variant
Dim Lname As String
LrecID = DLast("EmployeeID", "QryEmployeeClockIn", "EmployeeID=" & Me.EmployeeID)
LrecInOUT = DLast("InOut", "QryEmployeeClockIn", "EmployeeID=" & Me.EmployeeID)
LrecDate = DLast("TimeStamp", "QryEmployeeClockIn", "EmployeeID=" & Me.EmployeeID)
If Me.EmployeeID = LrecID And LrecInOUT = 0 Then
InOut.Value = -1
ElseIf Me.EmployeeID = LrecID And LrecInOUT = -1 Then
InOut.Value = 0
Else: InOut.Value = -1
End If
' I was thinking something like this:
' If Me.EmployeeID = LrecID And LrecInOUT = 0 and LrecDate is not within 5 minutes ago Then
' InOut.Value = -1
TimeStamp = Now()
DoCmd.GoToRecord acForm, "FrmEmployeeClockIn", acNewRec
ExitSub:
Exit Sub
ErrorHandler:
On Error GoTo ErrorHandler2
ErrorHandler2:
MsgBox "An error has occured, restart the form", vbOKOnly, "Error"
Resume ExitSub