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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with comparisons

Status
Not open for further replies.

Imconfused

Technical User
Aug 25, 2003
12
US
I am trying to build a query that will compare values in 2 different fields then display the greater value. Any ideas?
 
Case statement maybe? more details of what you are trying to accomplish will help determine the best way to proceed.

leslie
 
The table I am querying is very large (approx 38,000 records). Many of the fields contain certain values (dollars). Some of the fileds are reporting values that should match the value in a separate filed (within the same record). For reporting purposes I need to use the value in field "x" if it is equal to or greater than the corresponding value in field "y". If the corresponding value in field "y" is geater than the value in field "x", then I would want to use the "y" value. I want the query to do this for me. Please forgive me, everything I know about Access I have had to learn on my own.
 
Well, the query accepted the expression, however, no values are being displayed (I did check the "show" box). Below is the expression with the actual field names. BTW, thanks for your time.

IIf([Inducted Dollars]>=[JOQ Dollars],[Inducted Dollars],[JOQ Dollars])
 
I take that back, it did work except where there was a null value in some of the records (in one field). For the first several hundred records, the JOQ Dollars was null.
 
I may have misunderstood your original post, (sorry!) try this:


iif(field x >= field y, fieldx, iif(field y > field x, field y, ''))
 
IIf([Inducted Dollars]>=nz([JOQ Dollars]),[Inducted Dollars],[JOQ Dollars])

That should work...that'll turn the null JOQ dollars into 0's so the db can compare them. Hope the helps.

Kevin
 
Thanks, I finally got it to work using a combination of all of the suggestions. I had to use the Nz function in the JOQ Dollars field to convert the nulls into "0". Once that worked, everything else fell into place.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top