Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Stop data entry if certain criteria exists

I have a time reporting database that has a form with a start and stop time.

When the employee selects their name from a combo box and if they haven't entered a stop time in their previous transaction I have a message box appearing.  But the problem is, the message box is appearing for any employee even if they don't have "un-ended" transactions.

Here is my code.  Can someone spot the problem for me?

    If IsNull(DMax("[StopTime]", "tblLaborTranx", "[EmployeeID] = " & Forms!frmEmployeeLaborTranx!txtEmployeeID)) Then
        MsgBox "You have not logged out of your last labor transaction. Please be sure to log out of it or see the front office for editing."
        DoCmd.Close acForm, "frmEmployeeLaborTranx", acSaveNo
        Exit Sub
    End If

I also have tried:

    If DMax("[StopTime]", "tblLaborTranx", "[EmployeeID] = " & Forms!frmEmployeeLaborTranx!txtEmployeeID) = "" Then
        MsgBox "You have not logged out of your last labor transaction. Please be sure to log out of it or see the front office for editing."
        DoCmd.Close acForm, "frmEmployeeLaborTranx", acSaveNo
        Exit Sub
    End If

But that doesn't work either.

--Steve
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial