Null Values

S

Sarah

Hi

I have designed a database for all the Company Contracts, I would like to
design a query that selects the contract details in date order, (that bit i
can do) but my problem is, when sending out renewal letters sometimes I have
to send the letter to a difference address to where the equipment is. I want
to merge this query with a word document so that when it prints out the
letter if the renewal address is blank then it selects the address where the
equipment is. I have set up the renewal address and the equipment address as
two seperate tables. Hope somebody can help me. Thanks
 
K

kingston via AccessMonster.com

Try something like this in the address field in the query:

IIF(IsNull([RenewAddress]),[EquipAddress],[RenewAddress])
 
J

Jerry Whittle

What links the two tables together? In other words is there a primary key in
one table and a foriegn key in the other?

It would also help to know the exact table names and the name of the fields
holding the address data.
 
S

Sarah

Hi Jerry

The Contract number links the two tables together, which is the primary key
in both tables. The tables names are customers and Invoice Details. The
names of the fields holding the information are :-

Company Name
Renewal Name

Hope this makes sense

Sarah
 
J

Jerry Whittle

Try something like this with the all the names spelt properly:

Select [Company Name],
[Renewal Name],
IIf(IsNull([Company Name]) = True, [Renewal Name], [Company Name])
FROM customers, [Invoice Details]
WHERE customers.[Contract number] = [Invoice Details].[Contract number] ;
 
Top