Invalid Operation in Left Outer Join (in Access) (1 Viewer)

jdraw

Super Moderator
Staff member
Local time
Today, 17:21
Joined
Jan 23, 2006
Messages
15,379
Is this one of those issues where seeing your database or part of it might help in finding a solution?
You could post a copy of the database or significant part to highlight the issue.
 

plog

Banishment Pending
Local time
Today, 16:21
Joined
May 11, 2011
Messages
11,638
What happens when you LEFT JOIN the underlying tables of each query directly? Instead of building the queries you have, just bring in the tables to a new query and link them like you have in the final query. Perhaps that will give a better error message.
 

Micron

AWF VIP
Local time
Today, 17:21
Joined
Oct 20, 2018
Messages
3,478
I would first try removing both ORDER BY clauses. If that stops the error,

- put 1st back in & run. Regardless of the result

- remove 1st, add 2nd & run. Compare result.
Thinking that the ORDER By clauses may be in conflict. Another test might be to make a table from one at a time and pair the other query with the table to see if it's OK.
The tables for these are in the same db?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 16:21
Joined
Feb 28, 2001
Messages
27,138
The choice of LEFT or RIGHT for an OUTER JOIN must be based on which table is the independent table and which table is the dependent table.

The "LEFT" join says that the table to the left of the word JOIN in the SQL statement is the independent table. It at the very least implies that the table to the RIGHT of the word JOIN in the same statement is a dependent, or child table. The fact that something works when you use one direction of JOIN has at best limited bearing on whether the SQL would work using the other direction of JOIN.

Your comments in StackOverflow indicate that you have tried INNER and both flavors of OUTER JOIN - but that can't be right because the relationship cannot be quite so fluid. Not to mention that to implement a JOIN of that type, Access really wants you to have a key on the parent side of the JOIN. To do it right, the parent's key field should be unique though it doesn't have to be the PK of the table.

Rather than look at your code, why don't you tell us in words what it is that you want to achieve? Tell us the end goal WITHOUT resorting to code or SQL.
 

Micron

AWF VIP
Local time
Today, 17:21
Joined
Oct 20, 2018
Messages
3,478
More food for thought - are all fields involved in joins correct (e.g. CustNum and Location_ID don't appear to be related when considering their names)
.CustNum = qryStopsInfoInRoadnet.LOCATION_ID**
and you have an alias (PK) in one query and a field named PK in the other. While there may be more instances of either observation, I only note those two oddities.

Also, you haven't answered the question as to the location of the tables. You say the db is Access, but are the tables in an Access db as well, or are they sql server type tables?
EDIT - **I looked more at the other forum and see that you addressed that specific example. Just be sure that all the rest are of the same type, but still would consider any fields with the same name as any aliases.
 
Last edited:

Users who are viewing this thread

Top Bottom