UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> check to see if record exists    
 
   
swaziman1
post Aug 9 2008, 09:03 AM
Post #1

UtterAccess Ruler
Posts: 1,063



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
Go to the top of the page
 
+
Alan_G
post Aug 9 2008, 09:28 AM
Post #2

Utterly Yorkshire and Forum/Wiki Editor
Posts: 15,884
From: Devon UK



You can use the DCount() function along the lines of..........

CODE
If DCount("*","[NameOfYourTableToCheck]", "[IDField] = " & SomeID) > 0 Then
Msgbox "This record already exists", vbOKOnly + vbExclamation, "Duplicate Record"
End If
Go to the top of the page
 
+
swaziman1
post Aug 9 2008, 10:00 AM
Post #3

UtterAccess Ruler
Posts: 1,063



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?
Go to the top of the page
 
+
Alan_G
post Aug 9 2008, 10:03 AM
Post #4

Utterly Yorkshire and Forum/Wiki Editor
Posts: 15,884
From: Devon UK



Yes, you can use multiple criteria - eg

If DCount("*","[NameOfYourTableToCheck]", "[IDField] = " & SomeID & " AND [OtherField] = " & SomeOtherFiled) > 0 Then
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 23rd May 2013 - 06:14 AM

Tag cloud: