Hello,
I'm trying to get rid of duplicate entries for contacts. So in my contact entry form when the save buttom is clicked I want to use the DCount function to see if there are duplicates. Here is the code I'm trying to use -
If DCount("*", "contacts", [First_Name] = '" & _ Me.First_Name "' & [Last_Name] ='" & _ me.Last_Name " ') >0 Then
-
MsgBox "contact already exists"
-
Else
-
MsgBox "all good"
-
End If
-
-
It is not working and I've tried different ways to write it but I can't get it right. My fields are text fields.
Thanks in advance for the help
2 1851
Hi. If you've pasted your code from the actual module and not retyped it then there are some minor errors which are easy to correct. Your IF statement is currently: - If DCount("*", "contacts", [First_Name] = '" & Me.First_Name "' & [Last_Name] ='" & me.Last_Name " ') >0 Then
but it should be - If DCount("*", "contacts", "[First_Name] = '" & Me.First_Name & "' AND [Last_Name] ='" & me.Last_Name & "'") > 0 Then
Please be aware that having two contacts with the same name is quite a common occurrence and does not mean that they are necessarily duplicates - you could only tell this by looking at additional information which you don't specify here.
-Stewart
Thanks. And I was aware of the possibility of having people with the same first and last name. I'm using the company name as a third variable. So now it looks like so: - If DCount("*", "contacts", "[First_Name] = '" & Me.First_Name & "' AND [Last_Name] ='" & Me.Last_Name & "' AND [Company] ='" & Me.Company & "'") > 0 Then
-
And it works, so thanks so much for the help Stewart!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: tin |
last post by:
<script language="Javascript">
<!--
function apri (theURL,winName,features){
window.open (theURL,winName,features);
var a=null;
oldwindow = window.self;
oldwindow.opener = window.self;
oldwindow.close();
}
-->
|
by: neo88 |
last post by:
hi guys
Can anyone please tell me what is wrong with this function:
inline int strength(void) {
int a;
// tests to see what strength value the agent just attacked\defended
with
for (strength; a < 5; a++)
int strength = int power + int effect; // array of
strength
|
by: WindAndWaves |
last post by:
Can anyone tell me what is wrong with the goto command. I noticed it is one
of those NEVER USE.
I can understand that it may lead to confusing code, but I often use it like
this:
is this wrong?????
Function x
select case z
|
by: Dan Leeder |
last post by:
stroccur = DCount("", "empnotes", " = " & Chr(34) &
Me.Rpt_Card_Type & Chr(34) & " And = " & Me.SSN & " And #" &
& "# > " & DateSerial(Year(Me.datetime) - 1,
Month(Me.datetime), Day(Me.datetime)))
I'm using the above function to count similar records that have fallen
in the last year.
Ex:
SSN datetime cattype # of records in last year
|
by: SheldonMopes |
last post by:
I'm having difficulty with the DCount function, not getting the
results that I want.
Field1A and Field2A are fields in TableA matching Field1B and Field2B
in TableB
Using a calculated control in a subform bound to TableB, Field1B and
Field2B are on the form. (Control names are txtField1B and txtField2B)
| |
by: MLH |
last post by:
Public Function GetLastDayOfMonth(ByVal dtDay As Date) As Date
'**************************************************************************
' Accepts a date. Determines month & year of the date. Returns
' the date of the last day of that month (in the same year)
'**************************************************************************
GetLastDayOfMonth = DateSerial(Year(dtDay), Month(dtDay), 31)
End Function
If I enter dtDay value of...
|
by: sugaray |
last post by:
hi, below is my program for doing exercise with library time functions,
something is not right with it, and for the time being i couldn't figure
out what's wrong and where, thanx for your help.
#include <time.h>
#include <stdio.h>
double TimeDifference(struct tm *t1,struct tm *t2)
{
return difftime(mktime(t1),mktime(t2));
|
by: XZ |
last post by:
Hi everyone, this is really confusing to me:
#include <stdio.h>
main(int argc, char **argv) {
printf("argv = %f\n",(double)atof(argv));
printf("argv = %d\n\n",atoi(argv));
}
$ a.out a
argv = 97.000000
|
by: PengYu.UT |
last post by:
Hi,
I couldn't see what is wrong with the following program. Would you
please help me?
Thanks,
Peng
g++-3.4 -MM -g main.cc .dep
|
by: hirsh.dan |
last post by:
i have a functions that writes information to a file.
inside that function i have a line in which i call another function.
if this line is executed, nothing is written to the file, but if i
remark that line, it is written.
i wanna understand what's wrong and fix it, but can't find what is
wrong.
also this line is mandatory in my code.
the code attached is in the link, minimized to the needed info, a bit
different then the way it's...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |