Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Query Help, Showing Records Not In table

Posted on 2014-01-05
6
Medium Priority
?
328 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 2000 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

885 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