View Single Post
  #4  
Old June 1st, 2010, 10:59 PM posted to microsoft.public.access
lmcc via AccessMonster.com
external usenet poster
 
Posts: 3
Default Query--using Access 2007

Hey John,

I think I finally got your code to work. Below is what I created in a new
query and it seems to have done the job:

SELECT Address.*
FROM Company INNER JOIN Address ON Company.CompanyID = Address.CompanyID
WHERE (((Address.TypeOfAddressID)=(SELECT Min(Temp.TypeOfAddressID)
FROM Address as TEMP
WHERE Temp.CompanyID = Address.CompanyID)));

When I took a break and came back, then the code became clear of what you
were saying.

Thanks!!!


John Spencer wrote:
One method.

SELECT tblCompanies.*, tblAddress
FROM tblCompanies INNER JOIN tblAddress
ON tblCompanies.CompanyID = tblAddress.CompanyID
WHERE tblAddress.TypeOfAddressID =
(SELECT Min(Temp.TypeOfAddressID)
FROM tblAddress as TEMP
WHERE Temp.CompanyID = tblAddress.CompanyID)

If that is too slow then post back for an alternative query. When you do tell
us the names of the key fields and the names of the tables involved.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

I have a tblAddress table with a lookup field called TypeofAddressID.

[quoted text clipped - 9 lines]

Any suggestions?


--
Message posted via http://www.accessmonster.com