S
Sue
I have designed a contacts database which contains names of both personal &
business contacts. To avoid data entry errors, I have several tables which
relate to field in my tblContacts:
tblContactType:
ContactTypeID Autonumber
ContactType Text
tblCity
CityID Autonumber
City Text
tblState/Provinc
State/ProvinceID Autonumber
State/Province Text
tblZip/PostalCode
Zip/PostalCodeID Autonumber
Zip/PostalCode Text
tblContacts
ContactID Autonumber
ContactType
LastName Text
FirstName Text
HomeAddress Text
HomeCity Number Foreign key from
tblCity, relationship established enforcing referential integrity
HomeState/Province Number Foreign key from
tblState/Province, relationship established enforcing referential integrity
HomeZip/PostalCode Number Foreign key from
tblZip/PostalCode, relationship established enforcing referential integrity
BusinessAddress Text
BusinessCity Number Foreign key from
tblCity, relationship established enforcing referential integrity
BusinessState/Province Number Foreign key from
tblState/Province, relationship established enforcing referential integrity
BusinessZip/PostalCode Number Foreign key from
tblZip/PostalCode, relationship established enforcing referential integrity
I tried to develop a query that would allow me to pull out address
information for certain contact types. I found my queries returning void, so
I eliminated all but bare bones - just ContactType, LastName, FirstName -
and I find that I only return a small number out of a list of 700+ contacts.
In the design view of the query, I see relationship lines drawn for city,
state/province, zip/postal code, & country for both business and personal
adddresses. I assume that's the problem - that Access is returning only
those contacts where I have BOTH a business & a personal address. I've
pasted the SQL statement here. How can I get info for all contacts - those
with both personal & home address info, and those with neither (i.e. I have
some contacts that I only have a phone number or an email address for)?
SELECT tblContactType.ContactType, tblContacts.LastName,
tblContacts.FirstName
FROM [tblZip/PostalCode] AS [tblZip/PostalCode_1] INNER JOIN
([tblState/Province] AS [tblState/Province_1] INNER JOIN (tblCountry AS
tblCountry_1 INNER JOIN (tblContactType INNER JOIN (tblCity AS tblCity_1
INNER JOIN (tblCity INNER JOIN ([tblZip/PostalCode] INNER JOIN
([tblState/Province] INNER JOIN (tblCountry INNER JOIN tblContacts ON
tblCountry.Country_ID = tblContacts.HomeCountry) ON
[tblState/Province].[State/Province_ID] = tblContacts.[HomeState/Province])
ON [tblZip/PostalCode].[Zip/PostalCode_ID] = tblContacts.HomeZip) ON
tblCity.City_ID = tblContacts.HomeCity) ON tblCity_1.City_ID =
tblContacts.BusinessCity) ON tblContactType.ContactTypeID =
tblContacts.ContactType) ON tblCountry_1.Country_ID =
tblContacts.BusinessCountry) ON [tblState/Province_1].[State/Province_ID] =
tblContacts.[BusinessState/Province]) ON
[tblZip/PostalCode_1].[Zip/PostalCode_ID] = tblContacts.BusinessZip
ORDER BY tblContactType.ContactType, tblContacts.LastName,
tblContacts.FirstName;
business contacts. To avoid data entry errors, I have several tables which
relate to field in my tblContacts:
tblContactType:
ContactTypeID Autonumber
ContactType Text
tblCity
CityID Autonumber
City Text
tblState/Provinc
State/ProvinceID Autonumber
State/Province Text
tblZip/PostalCode
Zip/PostalCodeID Autonumber
Zip/PostalCode Text
tblContacts
ContactID Autonumber
ContactType
LastName Text
FirstName Text
HomeAddress Text
HomeCity Number Foreign key from
tblCity, relationship established enforcing referential integrity
HomeState/Province Number Foreign key from
tblState/Province, relationship established enforcing referential integrity
HomeZip/PostalCode Number Foreign key from
tblZip/PostalCode, relationship established enforcing referential integrity
BusinessAddress Text
BusinessCity Number Foreign key from
tblCity, relationship established enforcing referential integrity
BusinessState/Province Number Foreign key from
tblState/Province, relationship established enforcing referential integrity
BusinessZip/PostalCode Number Foreign key from
tblZip/PostalCode, relationship established enforcing referential integrity
I tried to develop a query that would allow me to pull out address
information for certain contact types. I found my queries returning void, so
I eliminated all but bare bones - just ContactType, LastName, FirstName -
and I find that I only return a small number out of a list of 700+ contacts.
In the design view of the query, I see relationship lines drawn for city,
state/province, zip/postal code, & country for both business and personal
adddresses. I assume that's the problem - that Access is returning only
those contacts where I have BOTH a business & a personal address. I've
pasted the SQL statement here. How can I get info for all contacts - those
with both personal & home address info, and those with neither (i.e. I have
some contacts that I only have a phone number or an email address for)?
SELECT tblContactType.ContactType, tblContacts.LastName,
tblContacts.FirstName
FROM [tblZip/PostalCode] AS [tblZip/PostalCode_1] INNER JOIN
([tblState/Province] AS [tblState/Province_1] INNER JOIN (tblCountry AS
tblCountry_1 INNER JOIN (tblContactType INNER JOIN (tblCity AS tblCity_1
INNER JOIN (tblCity INNER JOIN ([tblZip/PostalCode] INNER JOIN
([tblState/Province] INNER JOIN (tblCountry INNER JOIN tblContacts ON
tblCountry.Country_ID = tblContacts.HomeCountry) ON
[tblState/Province].[State/Province_ID] = tblContacts.[HomeState/Province])
ON [tblZip/PostalCode].[Zip/PostalCode_ID] = tblContacts.HomeZip) ON
tblCity.City_ID = tblContacts.HomeCity) ON tblCity_1.City_ID =
tblContacts.BusinessCity) ON tblContactType.ContactTypeID =
tblContacts.ContactType) ON tblCountry_1.Country_ID =
tblContacts.BusinessCountry) ON [tblState/Province_1].[State/Province_ID] =
tblContacts.[BusinessState/Province]) ON
[tblZip/PostalCode_1].[Zip/PostalCode_ID] = tblContacts.BusinessZip
ORDER BY tblContactType.ContactType, tblContacts.LastName,
tblContacts.FirstName;