Add Fields from Record

S

Scott

I have two tables. One has a unique PersonID with a lot of information about
the person (one to one). Another table has one to many records with
addresses associated with people. The 2nd table has an addressID and the
same person can have several address. Each address has an address type. As
it turns out, there is only one address type for each person, which helps me
in what I want to do.

I want to create a table that has a unique PersonID and a field in each
record for two of the types of addresses. In other words, one person has
what we call a HOR address and the same person has a Proposed HOR address. I
want to create a query/table that has the person's ID, a HOR field and a
Proposed HOR field. I want the table to be static, in the sense that I won't
be able to manipulate the records using VB to create a table each time the
query is run, because the query/table will be used to populate a Word
document that gets data from the table.

Ideas? Thanks.
 
J

John Spencer

3 query solution.

Build two queries that return the addresses. One for each type.

SELECT *
FROM AddressTable
WHERE AddressType = "HOR"

SELECT *
FROM AddressTable
WHERE AddressType = "Proposed HOR"

In a third query link those two queries to the Person table using an outer join.

SELECT <Person Stuff Fields>
, <HOR Address fields>
, <Proposed HOR Address fields>
FROM (PersonTable LEFT JOIN queryHORAddresses
ON PersonTable.PersonID = queryHORAddresses.PersonID)
LEFT JOIN queryProposedHORAddresses
ON PersonTable.PersonID = queryProposedHORAddresses.PersonID

Don't create a table to use this data. You should be able to use the
information directly from the query.

If you don't know HOW to use the SQL view to create queries and cannot figure
out the process to make the queries in design view, post back. I will try to
give you some step by step on doing all this in query design view.

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

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