So I'm trying to put a check on this table to prevent one user for putting more than one input per date. The problem is i cant do this with a primary key cause multiple users use the same table instead of creating the same table for hundreds of users.
I attempted to look up some sort of Dlookup function to check if the date and the employee ID # were the same as any of the other results but it doesn't seem to be working. If anyone has any suggestions thatd be greatly appreciated.
As of right now here is my code:
Private Sub Command11_Click()
Dim iEmpId As Long
iEmpId = Nz(DLookup("Emp_ID", "tblEmployeeDaily", "Emp_ID = '" & Me.Emp_ID & "' And " & "DailyDate=#'" & Me.DailyDate & "'"), 0)
If iEmpId <> 0 Then
MsgBox "An entry for this date already exists. " & vbCrLf & _
vbCrLf & "Please enter a different date.", _
vbCritical, "Duplicate Employee"
Cancel = True
Else:
DoCmd.Save acForm, "EmployeeDaily"
End If
End Sub
I attempted to look up some sort of Dlookup function to check if the date and the employee ID # were the same as any of the other results but it doesn't seem to be working. If anyone has any suggestions thatd be greatly appreciated.
As of right now here is my code:
Private Sub Command11_Click()
Dim iEmpId As Long
iEmpId = Nz(DLookup("Emp_ID", "tblEmployeeDaily", "Emp_ID = '" & Me.Emp_ID & "' And " & "DailyDate=#'" & Me.DailyDate & "'"), 0)
If iEmpId <> 0 Then
MsgBox "An entry for this date already exists. " & vbCrLf & _
vbCrLf & "Please enter a different date.", _
vbCritical, "Duplicate Employee"
Cancel = True
Else:
DoCmd.Save acForm, "EmployeeDaily"
End If
End Sub