electricjelly
Registered User.
- Local time
- Today, 14:22
- Joined
- Apr 3, 2014
- Messages
- 26
Hi I have been using the dlast function to look up the last record matching the inputted employee ID. I am trying to make it so that after looking up the last record access applies the opposite field to the [InOut] field however, it doesnt do anything and constantly applies a 0 (false) to the InOut field instead of doing the opposite.
Also I have a query in which it is referencing and the query is set to ascending order by date inputted so that the last record is always the most recently inputted.
Code:
On Error GoTo ErrorHandler
Dim LrecID As Integer
Dim LrecInOUT As Boolean
LrecID = DLast("EmployeeID", "QryEmployeeClockIn", "[EmployeeID]=" & Me.EmployeeID.Value)
LrecInOUT = DLast("InOut", "QryEmployeeClockIn", "[EmployeeID]=" & Me.EmployeeID.Value)
If Me.EmployeeID.Value = LrecID And LrecInOUT = 0 Then
InOut.Value = -1
ElseIf Me.EmployeeID.Value = LrecID And LrecInOUT = -1 Then
InOut.Value = 0
ElseIf DLast("employeeID", "qryEmployeeClockIN", "[EmployeeID]=" & Me.EmployeeID.Value) = Null Then
InOut.Value = -1
End If
TimeStamp.Value = 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