Hello Everyone,
I'm having some trouble with a query I'm trying to run and I cannot find any previous cases with solid solutions online...hoping someone could help!
Every month we receive a commission statement from a company we work with that has a list of names on it, along with other details regarding the commission being paid. We have a database in place that helps us keep track of these commissions and we want to implement a new feature that allows us to copy and paste data from the commission statements into a template and upload it into the database, and then run a query that matches the names from the statement(TableB) to the names in the database(TableA) so it can pull other relevant info from the database end.
The only issue is that the names don't always match up - either the name on the commission statement will only be a portion of what we have it stored under in the database or there will be a comma or period missing on one end. (i.e. in the database we have "Company A, LLC and the commission statement will have Company A LLC) I've set up a "Like" operator in the names column of the query that successfully returns results that partially match, however when punctuation is involved (such as my example) it will not return it. I'm not the greatest at coding or access but was wondering if there was a simple solution to this?
Current Like operator in the query is:
Field: Name
Table: TableA
Like "*" & [TableB].[Name] & "*"
Please let me know!
thanks,
Tim
9 2779 zmbd 5,501
Expert Mod 4TB
So to get a good starting point:
- You are able to consistently get: "Company A, LLC" or "Company A LLC" into your database
- the question is then being able to compare "Company A, LLC" to "Company A LLC" and recognize that these are the name company?
- Do you want to ignore all non-alphanumeric information in the company names (i.e. Company A, LLC == Company A - LLC == Company A$ LLC == Company A: LLC) or just specific characters such as the comma
- To do this for each company as listed Between the statement(TableB) to the names in the database(TableA)
Is this correct?
Or are you haveing issues getting the data into TableB too?
-z
How you described it is exactly correct - you even went a step further to something I didn't think about. I would like the query to recognize the varying formats from TableA and TableB as the same company, and if we could set it up to ignore all non-alphanumeric information that would be outstanding. (In theory this would solve the problem)
TableB is populated by by the "raw" data from the commission statements we receive that is imported via an excel template, so no issues there.
The problem with the LIKE operator in Access and SQL Server is that they are limited compared to regular expressions. And unfortunately, neither one has a regex implementation built into the SQL engine.
I'm afraid VBA is the only choice. Unless you don't mind casting a wide net. In which case you can replace all spaces in the clean table (tableB) with %.
hmmm..I gave it a few tries but couldn't get anything to work.
I first tried to use the "not a digit" ([!0-9]) pattern but it kept giving me an error saying it was invalid bracket name. The code looked like this:
Like "*" & [TableB].[Name] & "*" And Like [!0-9]
Even if this did work it still wouldn't solve the issue fully, as some of the "Names" have numbers in them. I tried figuring out a combination of the patterns to have it work but still no luck, as I want to return results that have punctuation, however ignore it while looking for matches. This must be possible! Thanks for your help so far!
My response was to zmbd's post...Just saw your Rabbit - using VBA would it be possible to get it to work? I'm open to spending a fair amount of time on this as it would save us a whole lot more in the long run...
zmbd 5,501
Expert Mod 4TB @Tim Mullin
Here's a function one that strips all non-numerics from the string. Even if we don't use it directly, we'll more than likely use the update query this talks about to clean up your table. http://support.microsoft.com/kb/210537
We should be able to modify the code... however, I think that the replace method might be easier. I'll play with that in a few momements after I get the next analysis started. :)
-z
zmbd 5,501
Expert Mod 4TB
Try the following:
I made a table called tblNamesDirty
[dirtyPK] autonumber (just because I like PK)
[DirtyNames] text(50)
Then I have the following function: - Option Compare Database
-
Option Explicit
-
-
-
Function RemoveNonAlphas(ByVal varDirty As Variant)
-
Dim strCleaned As String
-
Dim intPosition As Integer
-
Dim strCurrentLetter As String
-
'
-
'error trap
-
On Error GoTo z_errortrap
-
'
-
'start at the begining
-
intPosition = 1
-
If IsNull(varDirty) Then
-
RemoveNonAlphas = "Is_Null_Value"
-
Else
-
For intPosition = 1 To Len(varDirty)
-
strCurrentLetter = Mid(varDirty, intPosition, 1)
-
Select Case strCurrentLetter
-
'You could use a Ucase(strCurrentLetter)
-
'and then just compare on the uppercase letters
-
'however, I wanted to show that you could use ranges
-
'of charactors.
-
'
-
Case "A" To "Z", "a" To "z"
-
strCleaned = strCleaned + strCurrentLetter
-
Case " "
-
'I left the spaces in the string; however, I didn't
-
'want two spaces in a row, so I purge one if needed.
-
If Not Right(strCleaned, 1) = " " Then
-
strCleaned = strCleaned + strCurrentLetter
-
End If
-
End Select
-
Next intPosition
-
RemoveNonAlphas = strCleaned
-
End If
-
Exit Function
-
z_errortrap:
-
RemoveNonAlphas = "#Error"
-
End Function
I use this in a query such that - SELECT tblNamesDirty.[DirtyNames],
-
RemoveNonAlphas([DirtyNames]) AS [CleanName]
-
FROM tblNamesDirty;
In this case, when you run the query, there will be the column with the DirtyNames and then a column with the CleanName.
I used the select-case in this method because you can work with the data without a whole lot of grief.
Now you should be able to compare your two tables on the [CleanName]
(( You could also run this as an update query and clean the inbound table; however, I don't think that you'll need to do this...))
-z
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Frank |
last post by:
Can I store this PHP code in another page, then refernece it on
multiple pages using Require or Include ???
//results from sql query
for ($i=0; $i<$number; $i++) {
$ID =...
|
by: Uwe Brauer |
last post by:
Hello
In the w3c website:
http://www.w3.org/Style/Examples/011/firstcss
There is an example of a first attempt of a css. Is it possible that
Not only the form but also the content of...
|
by: Martin Magnusson |
last post by:
I have defined a number of custom stream buffers with corresponding in
and out streams for IO operations in my program, such as IO::output,
IO::warning and IO::debug. Now, the debug stream should...
|
by: bluekite2000 |
last post by:
Here A is an instantiation of class Matrix. This means whenever user
writes
Matrix<float> A=rand<float>(3,2);//create a float matrix of size 3x2
//and fills it up w/ random value
cout<<A;
the...
|
by: Roger Garrett |
last post by:
I'm having a problem with a derived class. When a copy is made of
the object it does indeed copy the additional member variables of
the object but it does not seem to be copying the members of the...
|
by: sonison.james |
last post by:
Why does C++ allow operator "->" to be overloaded but does not allow
operator "." to be overloaded?
Thanks and regards
SJ
|
by: diane100 |
last post by:
Hi
I am new to PHP and Smarty (I know only very basic things) and I need help with a warning message I get when I call a page in a browser.
I purchased some software from a company who are no...
|
by: v4vijayakumar |
last post by:
Can "c++ conversion operator" be considered as an example for
Prototype design pattern?
Following example explains, C++ conversion operator.
#include <iostream>
#include <string>
using...
|
by: none |
last post by:
I'm trying to overload the = operator using templates, but I have
some problems with one of the overloads, I would like to make
something like that:
intvariable = fooclass;
here's a pseudo...
|
by: C++Liliput |
last post by:
I have a custom String class that contains an embedded char* member.
The copy constructor, assignment operator etc. are all correctly
defined. I need to create a map of my string (say a class...
|
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...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |