473,394 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Duplicate Query from form

My problem is a bit long and involved, but I will try to summarize. I have created a database using Access 2000 for a cemetery and it now is populated with almost 6,000 names. I created a form so entries could easily be put in the table. In the Before_Update, I put this code to search for duplicates:

'check if last name, first name, and birth date are matched
If (Not IsNull(DLookup("LName", "Burials", "LName ='" & Me!LName & "'"))) _
And (Not IsNull(DLookup("FName", "Burials", "FName ='" & Me!FName & "'"))) _
And (Not IsNull(DLookup("BDate", "Burials", "BDate ='" & Me!BDate & "'"))) Then


'let user know name already exists
MsgBox "Name has already been entered.", vbInformation, "Duplicate Information"
Cancel = True

The problem with it is, it looks over the entire db everytime it sees a DLookup function. For example, let's say the person's name is Dorothy White and she was born on 1/30/1925. This code searches through the db and finds any matches for "White", then searches it again for first name of "Dorothy", then does it again for that birth date. I need the search to be in these three fields, because the primary key is an autonumber, and what are the odds any two ppl would have the same first and last name AND birth date.

I tried to change a duplicate query which I created with the wizard to reflect values found on the form:

SELECT First(Me!Burials.LName) AS [LName Field], First(Me!Burials.FName) AS [FName Field], First(Me!Burials.BDate) AS [BDate Field], Count(Me!Burials.LName) AS NumberOfDups
FROM Burials
GROUP BY Burials.LName, Burials.FName, Burials.BDate
HAVING (((Count(Me!Burials.LName))>1) AND ((Count(Me!Burials.BDate))>1));

I saved this query under the name Duplicate Query From Form. I want to plug it in using VBA in the Before_Update, and to recognize there is a return value, and give error msg accordingly. The problem is, I cannot figure out how to code this within the Before_Update module.

Am I just way off track in how I can accomplish this? I would GREATLY appreciate any help you could give :)
Jun 28 '07 #1
1 1766
MMcCarthy
14,534 Expert Mod 8TB
You can set more than one set of criteria on a DLookup and it doesn't matter in this case which value is returned.

Expand|Select|Wrap|Line Numbers
  1. 'check if last name, first name, and birth date are matched
  2.    If nz(DLookup("LName", "Burials", "LName ='" & Me!LName & "' And  FName ='" & Me!FName & "' And BDate ='" & Me!BDate & "'"), "") ="" Then
  3.  
By the way is BDate a string? If not, if it is a date then replace the single quotes with #
Jul 4 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: skennd | last post by:
Here's my problem in exact replication: I have used the find duplicate query in Access, and the query determined the following duplicate values by the following query: In (SELECT FROM As...
5
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone |...
8
by: Iona | last post by:
Hi Allan, I'm using a nifty piece of code you put on here some time back to do a duplicate entry check as below. I'm using to check for duplicate names. However I am getting an error message on...
4
by: afr0ninja | last post by:
Hello! I'm still rather new to using code in access. I've come across a problem that I'm having difficulty troubleshooting. Any assistance would be greatly appreciated! I've set up a form...
8
by: sixdeuce62 | last post by:
Hello, I am using Access 2002. I have read through 20 plus posts on here and I am still having trouble. My table consists of the following fields: Date Client ID
2
by: fabiola1 | last post by:
I'm using Ms Access 2003. I have five tables called tblAllContract tblType tbInteranlContact tblSupplier tblManager The other four tables are linked to tblAllContracts with Id's.I have a...
1
by: VinArt | last post by:
MS Acc 2003, XP Thank you in advance for any help. I have tables called "Makeup" and "Lines". Each makeup can have multiple lines. Goal is to create a new "makeup" with identical "lines"...
1
by: billesque | last post by:
Hello! I was wondering if it's possible to take a table in Microsoft Access that contains duplicate records (though not exactly identical) and create queries for use in a form. The form, currently...
1
by: xraive | last post by:
I have a problem with this. Currently I am trying Allen's code and i am not successful. Current Design Table1 (Main Form) TravelID (PK) ApprovedBY EntreredBy BudgetCode ExpenseCode
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.