Sharron, it would be possible to do this with a convoluted combination of
IIf() and DLookup() statements, but it would be considerably easier to
design a correctly normalized address system.
It seems that each client in your database could have more than one address,
such as a present address, a permanent address, and possibly other types.
This suggests a one-to-many relation between clients and addresses.
1. Create a small table to hold the possible address types. Just one field:
AddressTypeID Text (24 char) primary key.
Save the table as tblAddressType.
Enter a couple of records:
Present
Permanent
2. Create another table to hold the addresses. Fields:
AddressID AutoNumber primary key
ClientID relates to the primary key of your Client table.
AddressTypeID relates to tblAddressType.AddressTypeID
Priority Number 1 = top priority, 2 = second
choice, ...
Street
City
State
Zip
3. Remove all the address fields from your existing client table.
4. On your client form, create a subform for entering addresses. The subform
will automatically show only address for the client in the main form. Use a
combo for the AddressTypeID. Set Priority 1 for the preferred address.
5. Create a new query. Switch to SQL View (View menu). Paste this:
SELECT TOP 1 Street, City, State, Zip
FROM tblAddress
ORDER BY Priority, AddressID;
Save the query.
6. Presumably you already have an Access report as the "letter" you wish to
send. Create a subreport to show the address fields, based on the query
saved at step 5. The subreport acts as the address panel just below the name
in your report.
With this kind of structure, you can:
- have as many addresses as you want for any client;
- decide to add other types of address in the future (e.g. work, postal);
- set priorities for each kind of address easily;
- create other queries that show preference for a particular type of address
and so on.
A subquery might also be useful for selecting the preferred address. If
subqueries are new, see:
How to Create and Use Subqueries
at:
http://support.microsoft.com/?id=209066
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"SharronTucker" <(E-Mail Removed)> wrote in message
news:678F7CED-CA13-408F-8DE7-(E-Mail Removed)...
>I have a table with Permanent Address(yes/no) with
> Permstreet,permcity,permstate,permzip; then in same table Present
> Address(yes/no)with Presentstreet,prescity,prestate,preszip.
>
> How do I setup a query that will pull the permanent address if the
> Permanent
> Address is Yes OR the Present Address if the Present Address is Yes. I
> need
> to do this to send a letter to the address that should be used for
> mailing.