Convert Some field Entries to negative Numbers

T

Thorson

I have query set up that counts the number of entries in each category
("died" "sold" "euthanized" "born") in a specified field from a table. I
would like to change some of the category 'counts' to negative numbers while
leaving others positive. This way I can add up the total change in animal
numbers for a report.

An IIF statement did work, however the statement was too long for the query
field. The shortened statment is as follows:
NumberChanged:
IIf([DispMethod]="Died",([CountOfDispMethod]*-1),IIf([DispMethod]="Sold",([CountOfDispMethod]*-1)))

This equation works fine, but I still have 2 more categories to make
negative, which makes the equation to many characters to fit into the field.
Any suggestions?

Thanks
 
M

Michel Walsh

NumberChanged : iif( DisMethod IN("died", "sold", "xxx", "yyy"), -1, 1) *
ABS(countOfDispMethod)


Vanderghast, Access MVP
 
T

Thorson

Thank you! Works Great!

Michel Walsh said:
NumberChanged : iif( DisMethod IN("died", "sold", "xxx", "yyy"), -1, 1) *
ABS(countOfDispMethod)


Vanderghast, Access MVP


Thorson said:
I have query set up that counts the number of entries in each category
("died" "sold" "euthanized" "born") in a specified field from a table. I
would like to change some of the category 'counts' to negative numbers
while
leaving others positive. This way I can add up the total change in animal
numbers for a report.

An IIF statement did work, however the statement was too long for the
query
field. The shortened statment is as follows:
NumberChanged:
IIf([DispMethod]="Died",([CountOfDispMethod]*-1),IIf([DispMethod]="Sold",([CountOfDispMethod]*-1)))

This equation works fine, but I still have 2 more categories to make
negative, which makes the equation to many characters to fit into the
field.
Any suggestions?

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