Solved

Query Help, Showing Records Not In table

Posted on 2014-01-05
6
323 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

828 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