Solved

find duplicates in string in access query

Posted on 2014-09-15
6
491 Views
Last Modified: 2014-09-15
I need to write a  query that will identify if a string has duplicate words in it.

am in access query grid

not sure how.
0
Comment
Question by:PeterBaileyUk
  • 3
  • 2
6 Comments
 
LVL 35

Expert Comment

by:PatHartman
ID: 40323154
You can't do this with just a query.  You'll need to write a function that finds the duplicates.  You can then call the function from your query and select rows where the count is >1 or true or whatever you have your function return when it finds duplicates.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40323156
Peter, can you give an example?

"now is the time for all good men to come to the aid of their country"

this has 2 "to" and 2 "the",  but is that what you have in mind?  Do you need to do this in a query? is a function OK? are you looking for duplicates of any word, or just specific words?
0
 

Author Comment

by:PeterBaileyUk
ID: 40323163
"hello fred fred how are you"
"hello 110 this is 110 fred"

"this is fred and fred and fred a lots of them"
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:PeterBaileyUk
ID: 40323168
duplicates of any word. I dont need to know what they are just that a duplicate occurred for now.
0
 
LVL 35

Accepted Solution

by:
PatHartman earned 500 total points
ID: 40323208
I don't have the time to write this for  you (and that isn't our job here anyway) but one possible method is to use the split() function to split out all the words into individual array entries.  Then you loop through the array in the outer loop to pick up the next word and in the inner loop to find any duplicates.  However, you will probably want to make the loop smarter and once you have found how many instances of Fred exist, not allow the next instance of Fred in the outer loop to trigger the scan of the array again.

You also need to decide if you will exit the loop once you find ANY duplication (easiest) because if you need to report multiple sets of duplicates, you have to now create an array or table to hold them and some way to report on them.
0
 

Author Closing Comment

by:PeterBaileyUk
ID: 40323397
ok i will word around array
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question