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!

Query calculation with negative value

Status
Not open for further replies.

nunan

Technical User
Feb 11, 2004
41
0
0
GB
Hi there

Could someone please tell me what I am doing wrong?

If have 3 fields in a query that calculate values from various different places, then I have a fourth field that make a final calculation based on the values from the previous 3 fields.

The problem I am having is that one of the 3 fields will sometimes contain a negative value such as -4. My 4th field calculates correctly if there is not a negative value but if there is the calculation does not work.

For example, This is my current code:
DaysCharged: IIf([Ch2]<"0",[Ch1],[Ch3])

This returns the following values:
Ch1 Ch2 Ch3 DaysCharged
3 -4 7 7
3 -4 7 7
36 29 7 7
18 11 7 7

But what I need to be seeing is this:
Ch1 Ch2 Ch3 DaysCharged
3 -4 7 3
3 -4 7 3
36 29 7 7
18 11 7 7

I would appreciate any help

Thanks
 
Seems you play with strings instead of numeric values.
what about this ?
DaysCharged: IIf(Val([Ch2])<0,[Ch1],[Ch3])

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Perfect as usual! thanks PHV
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top