Solved

Access 2010 case sensitive join

Posted on 2012-03-13
6
1,415 Views
Last Modified: 2016-02-17
I've imported some Salesforce data into Access 2010 to join with data from a system called Summit Apex. We've added the Salesforce account id to Summit Apex in order to be able to integrate the two systems. The problem I'm having is that Salesforce account id's are case sensitive, but Access joins are not case sensitive.

For example, the id 0018000000YzcBe is not the same as the id 0018000000YzcBE in Salesforce. When I use the strcomp() function to make the left join case sensitive, I only get results back from the left table of the join and nothing from the right table. If I don't use the strcomp() function, then I get rows joined that should not be joined.

SELECT DISTINCT tApexDataBridge.Apex_Company, tApexDataBridge.Client_No, tApexDataBridge.PR_Spec, Salesforce_Accounts.[Parent Account ID], tApexDataBridge.SalesforceID, tApexDataBridge.Client_Name AS [Apex Account Name], Salesforce_Accounts.[Account Name] AS [Salesforce Account Name], tApexDataBridge.Term_Date AS [Apex Term Date]
FROM tApexDataBridge LEFT JOIN Salesforce_Accounts ON tApexDataBridge.SalesforceID = Salesforce_Accounts.[Account ID] AND STRCOMP(tApexDataBridge.SalesforceID, Salesforce_Accounts.[Account ID], 0) = 0
WHERE (((Salesforce_Accounts.[Termination Date]) Is Null))
ORDER BY tApexDataBridge.SalesforceID;
0
Comment
Question by:Perfishent
  • 4
  • 2
6 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 37715423
I can't see anything logically wrong, but I would try a simpler query and moving the strcomp expression into the Where clause, to see that you are getting matches when you expect.

So I would try first....This should produce all case-sensitive matches


SELECT A.*, B.*
FROM tApexDataBridge As A Inner JOIN Salesforce_Accounts As B
ON A.SalesforceID = B.[Account ID]
WHERE  STRCOMP(A.SalesforceID, B.[Account ID], 0) = 0
1
 

Author Comment

by:Perfishent
ID: 37720417
When I put the STRCOMP() function in the WHERE clause, I don't get any results at all.

SELECT tApexDataBridge.Apex_Company, tApexDataBridge.Client_No, tApexDataBridge.PR_Spec, Salesforce_Accounts.[Parent Account ID], tApexDataBridge.SalesforceID, tApexDataBridge.Client_Name AS [Apex Account Name], Salesforce_Accounts.[Account Name] AS [Salesforce Account Name], tApexDataBridge.Term_Date AS [Apex Term Date]
FROM tApexDataBridge LEFT JOIN Salesforce_Accounts ON tApexDataBridge.SalesforceID = Salesforce_Accounts.[Account ID]
WHERE (((Salesforce_Accounts.[Termination Date]) Is Null)) AND STRCOMP(tApexDataBridge.SalesforceID, Salesforce_Accounts.[Account ID], 0) = 0
ORDER BY tApexDataBridge.SalesforceID;
0
 
LVL 77

Expert Comment

by:peter57r
ID: 37720691
The point of my post was to try something simpler to establish whether any matches are being found, not to move strcomp within your original query.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:Perfishent
ID: 37778901
I simplified this down so that I'm not using a join but a sequence of dynamic update statements instead.

UPDATE tDataBridge SET [Salesforce Account Name] = 'Gerhart Cole Inc.', [Salesforce Account ID] = '001C000000q9Qgr' WHERE strcomp([Apex Salesforce Account ID],'001C000000q9Qgr',0) = 0

For some reason, the update statement is not updating the records when the id's match. Can you see anything wrong with the above SQL statement?

The Update statement is generated in the following loop:

                Set rst2 = db.OpenRecordset(sqltext)
                    Do While Not rst2.EOF
                        If rst2.RecordCount > 0 Then
                            sqltext = "UPDATE tDataBridge SET [Salesforce Account Name] = '" & Replace(rst2![Account Name], "'", "''") & "', [Salesforce Account ID] = '" & rst2![Account ID] & "' WHERE strcomp([Apex Salesforce Account ID],'" & rst2![Account ID] & "',0) = 0"
                             DoCmd.RunSQL (sqltext)
                        End If
                        rst2.MoveNext
                    Loop
                rst2.Close
0
 

Accepted Solution

by:
Perfishent earned 0 total points
ID: 37783279
I figured this problem out. Here's the code I used to get the join to work:

    sqltext = "SELECT tDataBridge.Apex_Company, tDataBridge.Client_No, tDataBridge.PR_Spec, tDataBridge.[Apex Salesforce Account ID], Salesforce_Accounts.[Account ID]," _
    & " tDataBridge.[Apex Client Name], Salesforce_Accounts.[Account Name], '' as Exact_Name_Match, tDataBridge.[Apex Term Date] INTO tDataBridgeCheck" _
    & " FROM tDataBridge LEFT JOIN Salesforce_Accounts" _
    & " ON (((StrComp(Trim([tDataBridge].[Apex Salesforce Account ID]),Trim([Salesforce_Accounts].[Account ID]),0))=0) AND ((Salesforce_Accounts.[Parent Account ID]) Is Null))"
0
 

Author Closing Comment

by:Perfishent
ID: 37800023
This was the only solution presented that worked.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
I showed you how to use console view (HERE (http://www.experts-exchange.com/articles/18379/Getting-Started-and-Using-the-Salesforce-com-Console.html)) -– but how do you set it up on the admin side of Salesforce? Note that you have to have Admin leve…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now