Solved

Query Help, Showing Records Not In table

Posted on 2014-01-05
6
319 Views
Last Modified: 2014-01-05
Experts, I have been having troubles with these queries.  I dont know what I am doing wrong.  It is quite simple but something seems to not be working.

If you look at the pared down db.
Open the query

It shows 2 records that are NOT IN tblLetterOfCredit on LCNo and L/C Ref
However, both of those records are in tblLetterOfCredit.
The only difference between them is a "-" dash but the function (StrippedChar) is suppose to remove the "-" and compare but the query still shows those 2 records as NOT IN tblLetterOfCredit.

What is happening?  These queries are about to drive me nuts because I think I understand what is happening but then what I learned goes out the window (as in this example).  

Please open the pared down db.  There is probably a simple answer to this that I cant see.
EE.accdb
0
Comment
Question by:pdvsa
  • 3
  • 3
6 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39758193
Check my explanation of unmatched queries, using LEFT JOINs in your earlier question, and try this since you're using a RIGHT JOIN:

SELECT [Import-DnB].[L/C Ref], tblLetterOfCredit.LCNo, StrippedChar([L/C Ref]) AS [LC Ref DNB], StrippedChar([L/C Ref]) AS [LCRef_Import-Dnb_Me], StrippedChar([LCNo] & "") AS LCNo_tblLetterOfCredit_Me
FROM tblLetterOfCredit RIGHT JOIN [Import-DnB] ON StrippedChar(tblLetterOfCredit.LCNo & "" )  = StrippedChar( [Import-DnB].[L/C Ref] & "")
WHERE  tblLetterOfCredit.LCNo IS NULL

Open in new window

0
 

Author Comment

by:pdvsa
ID: 39758269
Mbizup:  why do I get this error?   I copied and pasted from above.

Error

What makes it a RIGHT or LEFT qry?  In the query code above, there is not line drawn between the two tables but I do see it is a RIGHT join.  Maybe it doesnt show the line because of the error?

thank you
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39758282
It won't display in design view because of the functions that you need to make the comparison you want (not exactly an error).

Have you tried going directly from SQL to datasheet view?


--->> What makes it a RIGHT or LEFT qry?

Right and Left specify from which table ALL records are to be pulled.

eg in this JOIN, all records are pulled from table1 and only matching records from table2:

Table1 LEFT JOIN table2 ON Table1.ID = Table2.ID

Open in new window


Conversely, in this JOIN, all records are pulled from table2 and only matching records from table1:

Table1 RIGHT JOIN table2 ON Table1.ID = Table2.ID

Open in new window



Without design view as a visual aid, the RIGHT or LEFT simply means which side of the JOIN a table appears on in SQL view.
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:pdvsa
ID: 39758390
<Have you tried going directly from SQL to datasheet view?

Yes, I dont get the error.  

Shouldnt there be a line drawn between the 2 tables though?  It says RIGHT join so I am thinking there should be a line showing the relationship.

The bold and underlined is not needed, correct?  Also, if I delete simply the column I get errors when run...I have to delete the bolded below within the SQL.  

SELECT [Import-DnB].[L/C Ref], tblLetterOfCredit.LCNo, StrippedChar([L/C Ref]) AS [LC Ref DNB], StrippedChar([L/C Ref]) AS [LCRef_Import-Dnb_Me], StrippedChar([LCNo] & "") AS LCNo_tblLetterOfCredit_Me
FROM tblLetterOfCredit RIGHT JOIN [Import-DnB] ON StrippedChar(tblLetterOfCredit.LCNo & "" )  = StrippedChar( [Import-DnB].[L/C Ref] & "")
WHERE  tblLetterOfCredit.LCNo IS NULL

This is the final (I removed those columns from above):
SELECT [Import-DnB].[L/C Ref], tblLetterOfCredit.LCNo
FROM tblLetterOfCredit RIGHT JOIN [Import-DnB] ON StrippedChar(tblLetterOfCredit.LCNo & "" )  = StrippedChar( [Import-DnB].[L/C Ref] & "")
WHERE  tblLetterOfCredit.LCNo IS NULL

Open in new window



I really appreciate your explanations.  It seems like I would be best served using WHERE condition as Is Null in the testing criteria.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39758400
Did removing the underlined code work in SQL and datasheet view?

if so you are good to go.

The lack of a line in design view is not a problem.  This query as well as  other types of queries simply will not render in design view even though they are syntactically fine.  When that happens, you just need to stick to SQL and datasheet view (and not try to work in design view or worry about access's failed attempts at rendering it in design view)
0
 

Author Closing Comment

by:pdvsa
ID: 39758457
Thank you!  Good night....:)
0

Featured Post

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.

Question has a verified solution.

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

Suggested Solutions

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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.

863 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

21 Experts available now in Live!

Get 1:1 Help Now