SQL Help!!!

D

doodle

Windows xp, access 97
why diesn't crap work on saturdays?

I have a query that pulls from 4 tables. two of the tables have a field
named the same. "OnHand". I have stated in my wuery which one I want to
pull from. The query runs fine on it;s own, but when I run the report
that is based on this query, I get the following message:

The specified field 'qryAS400_UsageNew.OnHand' could refer to more than
one table listed in the FROM clause of your SQL statement.


thanks in advance,

-doodle

Here is my query:

SELECT DISTINCT qryAS400_UsageNew.PartNum,
qryAS400_UsageNew.PartDescrip, qryAS400_UsageNew.OnHand,
qryAS400_UsageNew.USAGE, IIf([sumofonhand] Is Null,0,[sumofonhand]) AS
ROH, IIf([sumofusage] Is Null,0,[sumofusage]) AS RU,
[qryAS400_UsageNew].[onhand]+[roh] AS TotalOnHand,
[qryAS400_UsageNew].[USAGE]+[ru] AS TotalUsage,
[totalonhand]-[totalusage] AS Var, qryAS400_UsageCores.CorePN,
qryAS400_UsageCores.OnHand, IIf([countofspindle type1] Is
Null,0,[countofspindle type1]) AS CAC
FROM ((qryAS400_UsageNew LEFT JOIN qryAS400_UsageRepairs ON
qryAS400_UsageNew.PartNum =
qryAS400_UsageRepairs.tblAS400_UsageRepairNum.PartNum) LEFT JOIN
qryAS400_UsageCores ON qryAS400_UsageNew.CorePN =
qryAS400_UsageCores.CorePN) LEFT JOIN qryAS400_UsageCoresOut ON
qryAS400_UsageNew.CorePN = qryAS400_UsageCoresOut.PartNum
WHERE (((qryAS400_UsageCores.OnHand)<>0));
 
G

Granny Spitz via AccessMonster.com

doodle said:
The specified field 'qryAS400_UsageNew.OnHand' could refer to more than
one table listed in the FROM clause of your SQL statement.

Try changing the qryAS400_UsageNew.OnHand column to an alias like
qryAS400_UsageNew.OnHand AS UNOH and use UNOH in your report.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top