Using count to avoid duplicates

Experts,
I have an unbound combo box control labeled cboStoreMgr. Before I update the control I would like to make sure that this employee has not already been assigned. I am checking against my table tblEmployee field EmployeeID and would like to use the COUNT
Frank FreeseAsked:
Who is Participating?
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
private sub cboStoreMgr_beforeupdate(cancel as integer)

if dcoun("*","tblEmployee","employeeid=" & me.cboStoremgr)>0 then
  msgbox "employee already assigned"
  cancel=true
  me.cbostoremgr.setfocus
end if


end sub
0
 
Frank FreeseAuthor Commented:
thank you
0
 
Dale FyeCommented:
I find it extremely annoying to think that I can do something (select an item in a list or combo, or click a command button), only to have the Click or some other event run a check and inform me that that selection is not currently available.

I would modify the query that is the RowSource so that those which are already appeared do not appear in the combo box.  If you provide a little more information about your form and the rowsource query, I might be able to rewrite that SQL for you.
0
 
Rey Obrero (Capricorn1)Commented:


if dcoun(   '<< missing "t"

should  be

if dcount(
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.