Check for duplicates using 2 fields

  • Thread starter Thread starter GMartin via AccessMonster.com
  • Start date Start date
G

GMartin via AccessMonster.com

I have read most of the data from the site concerning this and I still cannot
get anything to work. I am trying to check for duplicate data entry when
user input the information. I tried several ways using the before update
event. This is what I have.

Table name. tblCases and fields pkeyCaseNo (primarykey), SeqNo, and Facility
Form name. fmCases and textboxes Facility and Seq

I thought about a composite key but the way we record information it would
not work. Can anyone give me the answer in vb how to do the dlookup or
dcount to check on both the SeqNo and Facility to see if they have been used
together in another record? Both fields are number fields. pkeyCaseNo is
autonumber.

Thanks
 
If the following returns 1 (or more) then you have a duplicate.

Dcount("*","tblCases","SeqNo=" & me.SeqNo & " AND Facility=" & me.Facility &
"PkeyCaseNo <>" & mePkeycaseNo)

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Back
Top