Using count to avoid duplicates

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"
end if

end sub
Frank FreeseAuthor Commented:
thank you
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.
Rey Obrero (Capricorn1)Commented:

if dcoun(   '<< missing "t"

should  be

if dcount(
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.