473,385 Members | 1,311 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,385 software developers and data experts.

Help needed with First/Last Name combinations

Does anyone know of or have any VBA code or similar logic that can
help distinguish similar first/last name combinations? For example, we
would like to prompt the user of a possible match when any of the
first/last names Robert Smith, or Bob Smith, or Robt. Smith are used
during data entry. All that is necessary is to alert the user so that
they can review any appropriate existing records.

We have done several google searches without any luck. Any and all
help is appreciated.

TC

May 30 '06 #1
2 2485
On Tue, 30 May 2006 08:28:31 -0400, Tony Ciconte
<to******@comcast.net> wrote:

I have successfully integrated the Ratcliff/Obershelp algorithm, which
calculates the similarity between two strings. Anything over a certain
threshold would be run by the user: "Is it one of these?". AFAIK it is
only available in C.

-Tom.
Does anyone know of or have any VBA code or similar logic that can
help distinguish similar first/last name combinations? For example, we
would like to prompt the user of a possible match when any of the
first/last names Robert Smith, or Bob Smith, or Robt. Smith are used
during data entry. All that is necessary is to alert the user so that
they can review any appropriate existing records.

We have done several google searches without any luck. Any and all
help is appreciated.

TC


May 30 '06 #2
Tony Ciconte <to******@comcast.net> wrote:
: Does anyone know of or have any VBA code or similar logic that can
: help distinguish similar first/last name combinations? For example, we
: would like to prompt the user of a possible match when any of the
: first/last names Robert Smith, or Bob Smith, or Robt. Smith are used
: during data entry. All that is necessary is to alert the user so that
: they can review any appropriate existing records.

I wrote *very crude* code for this: it matches the alphanumeric
content of strings, *without any regard for order*, so although it
often works very well, you'll find some real howlers.
It sets a threshhold for matching that you can of course change.
Here's my code; excuse the numbers at the beginning of each line:
I got it from an Access export file before I learned how to export the
code alone.

--thelma

-----------------------------------------------------------------------

'------------------------------------------------------------------'
' RATEMATCH '
'------------------------------------------------------------------'
Function ratematch(ByVal listmember As String, _
ByVal guess As String) As Integer

372 '------------------------------------------------------------'
373 ' This Function computes a very crude 'match'-score for a '
374 ' tablemember as compared with a user entry that matched '
' no table member. It counts the alphanumeric characters '
' shared by the two, ignoring order and non alphanumeric '
' characters, but not collapsing duplicates. '
' Function Return: '
' 0=>match unlikely; 1=>exact match 2=>could be match '
378 '------------------------------------------------------------'
379
382
383 Dim guessLen As Integer
398 Dim gpos As Integer
399 Dim i As Integer
400 Dim lenNow As Integer
384 Dim ListMemberLen As Integer
401 Dim match As Integer

402 Dim nexletter As String

420 Dim mFrac As Single

380 listmember = _
OnlyAlphaNumericChars(listmember) ' Remove nonalphanumerics

381 guess = _
OnlyAlphaNumericChars(guess) ' from strings to compare

386 ratematch = 0 ' Not a Match

388 ListMemberLen = Len(listmember) ' Length of String from List
389 If ListMemberLen = 0 Then _
Exit Function ' Null is not Valid Guess

391 guessLen = Len(guess) ' Length of User Input

393 If InStr(listmember, guess) = 1 And ListMemberLen = guessLen Then
394 ratematch = 1 ' Exact alphanumeric Match
395 Exit Function
396 End If
397
404 match = 0

405
406 For i = 1 To guessLen
407 lenNow = Len(listmember)
408 If lenNow = 0 Then Exit For ' No string left to search
409 nexletter = Mid(guess, i, 1)
410 gpos = InStr(listmember, nexletter) ' Seek char in table entry

411 If gpos > 0 Then ' Char Found
412 match = match + 1 ' Increment matchcount
413 listmember = _
414 Left(listmember, gpos - 1) & _
415 Right(listmember, lenNow - gpos) ' Remove char matched
416 End If

417 Next
418
419 ' Accept if Fraction of name matched >= mFrac
421 If ListMemberLen > 4 And guessLen > 4 Then
422 mFrac = 0.8
423 Else
424 mFrac = 0.75
425 End If
426
427 If ListMemberLen > 0 And guessLen > 0 Then
428 If match / ListMemberLen >= mFrac And _
match / guessLen >= mFrac Then
429 ratematch = 2 ' Acceptable Alphanum Match
430 End If
431 End If
432
433 End Function
435 Public Function OnlyAlphaNumericChars(ByVal OrigString As _
436 String) As String
437

438 '------------------------------------------'
439 ' I found this function on the internet: '
440 ' DevX.com '

441 ' http://www.freevbcode.com/ '
442 ' Author: Intelligent Solutions Inc. '
443 '------------------------------------------'

444
445 '************************************************* **********
446 'INPUT: Any String

447 'OUTPUT: The Input String with all non-alphanumeric characters
448 ' removed
449 '************************************************* **********

450 Dim lLen As Long
451 Dim sAns As String
452 Dim lCtr As Long

453 Dim sChar As String
454 Dim zap As Boolean
455

456
457 OrigString = Trim(OrigString)
458 lLen = Len(OrigString)

459
460 zap = OrigString Like "*[!0-9A-Za-z]*"
461 If zap = False Then

462 OnlyAlphaNumericChars = OrigString
463 Exit Function
464 End If

465
466 For lCtr = 1 To lLen
467 sChar = Mid(OrigString, lCtr, 1)

468 ' If IsAlphaNumeric(Mid(OrigString, lCtr, 1)) Then
469 If sChar Like "[0-9A-Za-z]" Then
470 sAns = sAns & sChar

471 End If
472 ' DoEvents '(optional, but if processing long string,
473 'necessary to prevent program from appearing to hang)

474 'if used, write your app so no re-entrancy into this function
475 'can occur)
476 Next

477
478 OnlyAlphaNumericChars = sAns
479

480 End Function
481
482 Private Function IsAlphaNumeric(sChr As String) As Boolean

483 IsAlphaNumeric = sChr Like "[0-9A-Za-z]"
484 End Function
485
-----------------------------------------------------------------------
: We have done several google searches without any luck. Any and all
: help is appreciated.

: TC

May 30 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Simon | last post by:
Hi, I have a table with a column that contains many names, like "Ant Simon Lucy", if I was looking for one name in the string of names I would do... SELECT * from classroom where name LIKE...
1
by: PT | last post by:
I got a problem. And thats..... First of all, I got these three tables. ------------------- ------------------ ---------------------- tblPerson tblPersonSoftware ...
5
by: Chris Kettenbach | last post by:
Good Morning, Sorry for xposting. Just need a liitle help. I have an xml file that's generated from a database. How do I select distinct values from a field in xslt and then loop through the...
4
by: Chris Kettenbach | last post by:
Hi Peter, I get error when processing the stylesheet. It errors here. <xsl:for-each select="registration)=1]"> specifically: Expression does not return a DOM node. registration)=1]<--
6
by: Jamal | last post by:
I am working on binary files of struct ACTIONS I have a recursive qsort/mergesort hybrid that 1) i'm not a 100% sure works correctly 2) would like to convert to iteration Any comments or...
4
by: Norman Fritag | last post by:
Hi there, >>>__ 1020.83, 2305.22, 1176.86, 755.12, 123.41 __ 1976.1, 1325.99, 947, 718.03, 414.32 __ 1020.83, 1976.1, 352.5, 947, 718.03, 366.98 Their IDs were as...
5
by: thetrueaplus | last post by:
Hey all. I have bit shifted my enum values all the way to 31 items. I feel that this api that i am using continues to grow, i will be stuck with out any more items in my enum. I would like...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
2
by: rookiejavadude | last post by:
I'm have most of my java script done but can not figure out how to add a few buttons. I need to add a delete and add buttong to my existing java program. Not sure were to add it on how. Can anyone...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.