Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nested if

Status
Not open for further replies.

cjones

Technical User
Apr 7, 2001
22
0
0
US
This is a continuation of a problem that Alex helped me with earlier (thanks Alex!). I have an organizational alumni report. My database has home & work phone numbers. The the report lists the work or home phone number but not both. I want an (H) to print if home phone is listed or a (W) to print if work. Before I had to narrow it down to just 1 phone number I had the code listed in with the mask for each field but now that will not do.

I tried a new field that will list the H or W code but my sql statement does not work. It says unmatched ,. I know there is a problem with me using a nested if.

=IIf(isnull([Work_Phone]), IIf(isnull([Home_Phone]), , ”(H)”),“(W)”)

pseudocode
if workphone is null
if homephone is null
do nothing
else
print (H)
else
print (W)

OR can my original statement used to print the phone numbers be changed to list the phone number with the correct code?

=Trim(IIf(IsNull([Work_Phone]),[Home_Phone],[Work_Phone]))

This is the last report in a long project. Thanks for you help!!
Christine
 
If you just want to add it on after the phone numbers themselves you can try something like this:

=Trim(IIf(IsNull([Work_Phone]),[Home_Phone] & " (H)",[Work_Phone] & " (W)"))

I think that's what you're looking for...hope that helps.

Kevin
 
Thanks!! I tried doing that but without the &. Now it works!!!!!! Such a happy day. Thanks kevin.
 
Hi :)

Just realized there is a problem with a few of the records. There are just a few people who do not have any phone number listed. For these people the report now defaults to printing an (H). Am I going to have to use the nested if? So close...
 
Try this:

=Trim(IIf(IsNull([Work_Phone]),IIf(IsNull([Home_Phone]), "No Phone Number", [Home_Phone] & " (H)"),[Work_Phone] & " (W)"))


Hope the helps (and works) Christine.

Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top