How do I set up or validate cardinalities, such as (0,5), in MS A.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to set up a validation that will make sure that a particular
employee has no more than five patients personally assigned to them. I have
a patient table with the employee Id set as a field. I have been trying to
write an expression in Visual Basic, but I have not yet gotten it to work. I
think that I am using the DCount function wrong. Any help with that would be
greatly appreciated. All fields involved are CHAR(5). I wonder if this type
of cardinality is even possible with MS Acess.
 
Try

If DCount("*","TableName","[Employee Id] = " & EmployeeId) > 5 Then
Msgbox "More then 5"
End If

If the employee id is text, try
DCount("*","TableName","[Employee Id] = '" & EmployeeId & "'")

Note:
[Employee Id] - the name of the field in the table
EmployeeId - the name of the variable
 
Back
Top