Access Query in 2007

Access 2007 freaks out (“JOIN not supported”) when I put constant expressions in my left joins.  I originally wrote this query in Access 2003, and it still works in Access 2007 as long as I don’t make any edits, but if I change anything (e.g., add a return to the end) , it won’t compile.  If I take out the company part and latest cost, the query runs (but I get the wrong results, naturally).

Any idea how to include clauses like this in Access 2007?
-----
SELECT [AFAs].afa, sum( [quantity] * NZ( [Latest Cost].[Factory Cost] * NZ(1+[MRB/APB],1),List_Price )) AS [Total  Part Cost]
FROM ((AFAs LEFT JOIN Installed_Components ON [Installed_Components].AFA = [AFAs].afa) LEFT JOIN [Latest Cost] ON
   ([Latest Cost].[Part Number] = [Installed_Components].[part_number])
   AND
   ([Latest Cost].[condition] = [Installed_Components].[part_condition] )
   AND
   ( [cpart]='Company Part')
  AND
   ( [Latest Cost].[Factory Cost] > 0)
 ) LEFT JOIN [2011 Purchase complete parts] ON  [2011 Purchase complete parts].[Material]  = [Installed_Components].[part_number] AND Installed_Components.part_condition='new'
GROUP BY [AFAs].afa;
gannon24Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Does it only freak out in the query grid design view. or even if you try to run it directly from the SQL view?

mx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dale FyeCommented:
Joins are meant to relate fields in two or more tables.

You are going to need to remove the [cpart], [Factory Cost], and [part_condition] sections from the joins and place those either in a WHERE clause or a Having clause
0
Dale FyeCommented:
Try:

SELECT [AFAs].afa,
 sum([quantity] * NZ([Latest Cost].[Factory Cost] * NZ(1+[MRB/APB],1),List_Price )) AS [Total  Part Cost]
FROM ((AFAs
LEFT JOIN Installed_Components ON [Installed_Components].AFA = [AFAs].afa)
LEFT JOIN [Latest Cost] ON [Latest Cost].[Part Number] = [Installed_Components].[part_number]
                                     AND [Latest Cost].[condition] = [Installed_Components].[part_condition])
LEFT JOIN [2011 Purchase complete parts]
ON  [2011 Purchase complete parts].[Material]  = [Installed_Components].[part_number]
WHERE [cpart]='Company Part'
  AND [Latest Cost].[Factory Cost] > 0
  AND Installed_Components.part_condition='new'
GROUP BY [AFAs].afa;
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

peter57rCommented:
I know this syntax has worked at some point in the past, but for my A2003 set up it no longer does.

To handle the problem of the left join you have to build a subquery that does the select and then left join to that.

So like ...

Select A.*, Q1.* from A
left join
(Select * from B where B.field1= 123) as q1
on A.fieldx= q1.fieldy
0
gannon24Author Commented:
mx it is in both views (query and design)
0
Jeffrey CoachmanMIS LiasonCommented:
<but if I change anything (e.g., add a return to the end)>
...what does this mean exactly...?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.