Full Version: check to see if record exists
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
swaziman1
HI,
Is there a way I can see if a record exists in a table?
something along the lines of 'if is in [IDField] then msgbox "this record already exists"?
thanks
Alan_G
You can use the DCount() function along the lines of..........
!--c1-->
CODE
If DCount("*","[NameOfYourTableToCheck]", "[IDField] = " & SomeID) > 0 Then
Msgbox "This record already exists", vbOKOnly + vbExclamation, "Duplicate Record"
End If
swaziman1
thanks , will that also work if i want to se if there is a combination of id's? for example if ID1 and ID2 are in the same record?
Alan_G
Yes, you can use multiple criteria - eg
If DCount("*","[NameOfYourTableToCheck]", "[IDField] = " & SomeID & " AND [OtherField] = " & SomeOtherFiled) > 0 Then
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.