My Assistant
![]() ![]() |
|
|
May 11 2009, 04:13 PM
Post
#1
|
|
|
UtterAccess Veteran Posts: 313 |
I have two tables (Customer and Jobs).
I created a sample query below: SELECT Customer.ContactLastName, Customer.JobNumber, Jobs.QuanityUsed, Jobs.Cut FROM Customer INNER JOIN Jobs ON Customer.JobID = Jobs.JobID; When I run this query it lists multiple listings for Customder.ContactLastName if there are more than 1 job for that customer. What I want is to run the query, and if there is one or more jobs for one customer to list them one time. Thanks |
|
|
|
May 11 2009, 05:31 PM
Post
#2
|
|
|
UtterAccess VIP Posts: 20,187 From: Colorado |
Do you have an autonumber field in the Jobs table? If so, you might want to list the most recently added Job. Assuming the autonumber field is called JobID and it is sequential:
SELECT Customer.ContactLastName, Customer.JobNumber, Jobs.QuanityUsed, Jobs.Cut FROM Customer INNER JOIN Jobs ON Customer.JobID = Jobs.JobID WHERE JobID = dMax("JobID","Jobs","CustomerID =" & Customers.CustomerID ) WHERE CustomerID is the key field in Customers, probably an autonumber BUT! I see you have JobID in the Customers table instead of CustomerID in the Jobs table ... you should have only one record for each Customer. If you have multiple contacts depending on the job, that information should be in the Jobs table If you may have multiple Contacts for a Job, you would want to create a related table for JobContacts For better understanding of the basics of Access, read this: Access Basics http://www.utteraccess.com/forums/showflat...;Number=1595005 free 100-page tutorial that covers essentials in Access |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 18th May 2013 - 07:01 PM |