G
Guest
I admit that Access is not my strong suit. I am just now starting to work
with it on a regular basis. With that said, I need some help with this one
problem.
There is a database that contains multiple tables. Each one is linked by a
ContactID number. One table has the names and personal information. One table
contains the addresses, because one ContactID can have multiple addresses
(home and business). One table contains how much they have donated.
I have created a query linking these tables together so I can get a list of
all the donations made this year and their addresses, so we can form a report
later on. Here is the problem. I need to only get one address per ContactID
and their home takes priority over their business, if they have both.
Currently, the query will list their information twice if they have two
AddressID's. Make sense?
For example, I have a ContactID number for the Jones family. In our database
that ContactID has two separate AddressID's associated with it, because they
listed their home and business. In this database, that is designated by
ContactType with a text field for "Home" and "Business".
When I run the query now, it will list two rows for the Jones -- one for the
home and one for the business. In our case this is redundant and not needed,
because their donations are the same and are being listed twice. I thought I
could fix this with a IIF statement in the query, but no luck. Someone else
mentioned using a SQL Union and somehow picking just the first entry for each
ContactID. But I don't know how to do that.
Here is the logic if you need it:
If ContactID.ContactType has both Home and Business
Return only Home
Else
Return Business
Any help would be appreciated. Thanks. If you need any more information from
me please ask.
with it on a regular basis. With that said, I need some help with this one
problem.
There is a database that contains multiple tables. Each one is linked by a
ContactID number. One table has the names and personal information. One table
contains the addresses, because one ContactID can have multiple addresses
(home and business). One table contains how much they have donated.
I have created a query linking these tables together so I can get a list of
all the donations made this year and their addresses, so we can form a report
later on. Here is the problem. I need to only get one address per ContactID
and their home takes priority over their business, if they have both.
Currently, the query will list their information twice if they have two
AddressID's. Make sense?
For example, I have a ContactID number for the Jones family. In our database
that ContactID has two separate AddressID's associated with it, because they
listed their home and business. In this database, that is designated by
ContactType with a text field for "Home" and "Business".
When I run the query now, it will list two rows for the Jones -- one for the
home and one for the business. In our case this is redundant and not needed,
because their donations are the same and are being listed twice. I thought I
could fix this with a IIF statement in the query, but no luck. Someone else
mentioned using a SQL Union and somehow picking just the first entry for each
ContactID. But I don't know how to do that.
Here is the logic if you need it:
If ContactID.ContactType has both Home and Business
Return only Home
Else
Return Business
Any help would be appreciated. Thanks. If you need any more information from
me please ask.