Help with Query

JerryEng
11-21-2002, 03:11 PM
I have 3 tables: Jobs; JobCosting; TimeSlips.

Jobs contains fields :
JobNumber (primary key)
JobName


JobCosting contains fields:
CostTicket (primary key)
JobNumber
ItemNumber
Quantity

TimeSlips contains fields:
TimeSlipNum(primary key)
EmployeeID
JobNumber
Hours

I'm trying to write a query that will return all items used on a job and all time applied to the job. Some jobs may have only items. Some jobs may only have time.

I used the query wizard in Access and it came up with this:

SELECT Jobs.JobNumber, Jobs.JobName, JobCosting.ItemNumber, JobCosting.Quantity, TimeSlips.EmployeeNum, TimeSlips.Hours
FROM (Jobs INNER JOIN TimeSlips ON Jobs.JobNumber = TimeSlips.JobNum) INNER JOIN JobCosting ON Jobs.JobNumber = JobCosting.JobNumber
WHERE (((Jobs.JobNumber)=[?]));



This works fine if a job has both items and time but returns nothing if a job has only time or only items.
How can I modify the query so that data is returned even if there are records only in JobCosting or TimeSlips?

Ultimately, I'm trying to generate a report that will show all costs associated with a particular job.

Any help would be greatly appreciated!!

DerFarm
11-21-2002, 03:21 PM
You'll have to use a left (or right) join.

In your query in the Query box, RIGHT click on the line that shows the inner join. You'll get a selecttion box that has three choices.

The one you want will say something like Take all from Jobs and only from .... that matches.

JerryEng
11-21-2002, 03:35 PM
Thanks,
I'll give that a try!!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum