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

If statement with within query

Status
Not open for further replies.

masalachol

Technical User
Apr 8, 2004
20
US
I am trying to do the following in a query without success. Any suggestions


If ParseOne+ParseTwo-Imp3=-0.01
then
0.01+ParseTwo
Else
ParseTwo

OR

If ParseOne+ParseTwo-Imp3=0.01
then
ParseTwo-0.01
Else
ParseTwo



P2: IIf(([ParseOne]+[ParseTwo])-([Imp3])="-0.01",0.01+[ParseTwo],[ParseTwo]) & IIf(([ParseOne]+[ParseTwo])-([Imp3])="0.01",[ParseTwo]-0.01,[ParseTwo])

Instead of getting one value in the query field .... I am getting both values ie P2
5.485.47..... it should either be 5.48 or 5.47

-
 
Have you tried this ?
P2: IIf(ParseOne+ParseTwo-Imp3=-0.01,0.01+ParseTwo,IIf(ParseOne+ParseTwo-Imp3=0.01,ParseTwo-0.01,ParseTwo))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
The code you have is concatenating two strings generated by the two IIF statements. I think that you really want the results from only one of the IIF statements. Try this
Code:
P2: 
IIf(([ParseOne]+[ParseTwo])-([Imp3])=-0.01,",[ParseTwo]+0.01,
IIf(([ParseOne]+[ParseTwo])-([Imp3])=0.01,[ParseTwo]-0.01,[ParseTwo])
I'm assuming that "[ParseOne]", "[ParseTwo]" AND "[Imp3]" are all numeric fields.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top