My Assistant
![]() ![]() |
|
|
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 |
|
|
|
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 |
|
|
|
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?
|
|
|
|
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 Top · Lo-Fi Version | Time is now: 23rd May 2013 - 06:14 AM |