C
Chip R.
I'm using an OBDC link to import Timberline database info into
access.. I am now trying to build a query, and having much difficulty
doing it.
I've got a lot of fields I'm trying to bring in:
Quote Number
Date
Salesperson
Estimator
Value
Contact
Company
ProjectName
Score
Job Number
All of the above is in a number of different databases and I'm using
inner joins to get them.
Anyway, there is more than one contact stored with each job, and those
contacts have different "Roles" that they're stored as. They might be
the architect involved, the general contractor, the owner... And
herein lies the problem. I only want the Contact whose Role is 'GC
(primary)'. And if there is no 'GC (Primary)', I want the 'Owner
(Primary)'. However, sometimes one particular job has both of those
types of contacts, and I only want one, the 'GC (Primary)'. I don't
know how to do that. I can get all of the info for one particular
role, I can get all the info for both roles, but I can't get the info
for one or the other.
Is there a way to do this?
I've thought about using a UNION statement to pull both, and then the
fact that UNION is distinct it would get rid of the duplicates that I
don't want. However, this doesn't work, and I get some "non unique
table reference" error. Someone recommended using a subquery, but I
don't know how I would use it to get what I want. An IIf statement
seems like an interesting idea, but there's a possiblity that in the
end I'd want to use SQL to pull the Timberline data straight into
Excel without any Access use at all, and it seems like IIf is only an
Access command.
If someone could help me, even just by pointing me in the right place
or direction so I can figure out how to do this myself, I'd appreciate
it a lot. I am very new to SQL and access in general.
Thanks,
Chip
(Please respond to the message board, not by e-mail)
access.. I am now trying to build a query, and having much difficulty
doing it.
I've got a lot of fields I'm trying to bring in:
Quote Number
Date
Salesperson
Estimator
Value
Contact
Company
ProjectName
Score
Job Number
All of the above is in a number of different databases and I'm using
inner joins to get them.
Anyway, there is more than one contact stored with each job, and those
contacts have different "Roles" that they're stored as. They might be
the architect involved, the general contractor, the owner... And
herein lies the problem. I only want the Contact whose Role is 'GC
(primary)'. And if there is no 'GC (Primary)', I want the 'Owner
(Primary)'. However, sometimes one particular job has both of those
types of contacts, and I only want one, the 'GC (Primary)'. I don't
know how to do that. I can get all of the info for one particular
role, I can get all the info for both roles, but I can't get the info
for one or the other.
Is there a way to do this?
I've thought about using a UNION statement to pull both, and then the
fact that UNION is distinct it would get rid of the duplicates that I
don't want. However, this doesn't work, and I get some "non unique
table reference" error. Someone recommended using a subquery, but I
don't know how I would use it to get what I want. An IIf statement
seems like an interesting idea, but there's a possiblity that in the
end I'd want to use SQL to pull the Timberline data straight into
Excel without any Access use at all, and it seems like IIf is only an
Access command.
If someone could help me, even just by pointing me in the right place
or direction so I can figure out how to do this myself, I'd appreciate
it a lot. I am very new to SQL and access in general.
Thanks,
Chip
(Please respond to the message board, not by e-mail)