I thought this would be a simple Query; however I can't figure it out.
I have a list of Bank Transactions with a Description and dollar amount. I want to assign each transaction to a tenant based on one or more keywords that identifies that tenant. However I also want to exclude any transactions that contain an exclude-word for that tenant.
For example I may have a tenant called 'Sara' who has deposits that I can find by a Keyword of 'Sara'; however I want to exclude deposits that contain 'Sarah' because they belong to someone else. This is a simple example; however they can be much more random with many keywords and exclude words.
So I have the following 4 tables...
Bank Table
ID Description Amount 1 This was Pauls Payment $100.00 2 This a Test Payment $100.00 3 The Cat in The Hat $100.00 4 Paul $100.00 5 I Love Sara today $100.00 6 Sarah pay $100.00 7 This was Paul and Zoe's payment $100.00 8 Zoe, Paula and Paul Waz Hair $100.00 9 Paul Jones Payment $100.00
Tenant Table
ID FirstName LastName 1 Paul Jones 2 Sara Jane 3 Honey Cat 4 Test LastName 5 Sarah Smith
KeyWord Table
ID TanantID KeyWord 1 1 Paul 2 1 Higgins 3 2 Sara 4 3 Honey 5 3 Cat 6 4 Test 7 4 Last 8 4 Name 9 5 Sarah 10 5 Smith
ExcludeWord Table
ID TanantID ExcludeWord 1 1 Jones 2 1 Paula 3 2 Sarah 4 3 Dog 5 5 Sara
How do I create a Query to match up each Bank transaction to each Tenant? based on the Keyword and exclude word?
Here is an example how NOT to do it...
SELECT Bank.ID, Bank.Description, [Include-Exclude].KeyWord.TanantID, [Include-Exclude].KeyWord, InStr(1,[Description],[KeyWord],1) AS [Include#], [Include-Exclude].ExcludeWord.TanantID, [Include-Exclude].ExcludeWord, InStr(1,[Description],[ExcludeWord],1) AS [Exclude#]
FROM Bank, [Include-Exclude]
WHERE (((InStr(1,[Description],[KeyWord],1))>0) AND ((InStr(1,[Description],[ExcludeWord],1))=0));
I will be very impressed by whoever can solve this!
:-)