Solved

Query Help, Showing Records Not In table

Posted on 2014-01-05
6
318 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
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.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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

21 Experts available now in Live!

Get 1:1 Help Now