the iif function in a query

G

Guest

i have the following function:

Home Team Results: IIf([Home Team Score]>[Visiting Team Score],"Win","Loss")

However, There are games not played yet that have null values for the [home
team score] and [visiting team score] when I run the querry is shows a loss
for each record that hasn't had any scores added to it.

Question: how can I leave the home team results field blank if no score has
been added to the fields.

thanks.
 
G

Guest

First test for one of the score's being Null. Only if this is the case
compare the scores:

IIf(IsNull([Home Team Score]),"",IIf([Home Team Score]>[Visiting Team
Score],"Win","Loss"))

Ken Sheridan
Stafford, England
 
J

Jeff Boyce

IIF(Nz([HomeTeamScore],"")="",[HomeTeamScore],IIF([HomeTeamScore]>[VisitingTeamScore],"Win","Loss"))

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

Guest

Tried it and it works perfectly...

Thanks alot

Ken Sheridan said:
First test for one of the score's being Null. Only if this is the case
compare the scores:

IIf(IsNull([Home Team Score]),"",IIf([Home Team Score]>[Visiting Team
Score],"Win","Loss"))

Ken Sheridan
Stafford, England

BrianPaul said:
i have the following function:

Home Team Results: IIf([Home Team Score]>[Visiting Team Score],"Win","Loss")

However, There are games not played yet that have null values for the [home
team score] and [visiting team score] when I run the querry is shows a loss
for each record that hasn't had any scores added to it.

Question: how can I leave the home team results field blank if no score has
been added to the fields.

thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top