If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Add Fields from Record
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. |
#2
|
|||
|
|||
Add Fields from Record
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 Scott wrote: 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. |
Thread Tools | |
Display Modes | |
|
|