Solved

Access 2010 case sensitive join

Posted on 2012-03-13
6
1,475 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

776 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