473,395 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Change A Negative Number To Zero

3
Access 2013

Alright so I have some data here and I have it so you can see how many products u have in stock and how many the reorder level is. The Amount To Order field will display a number and if its positive thats how many items you need to order to bring your stock back up to the right level. If its negative it means you dont need to order any. I want it to say 0 instead of -20 for example. How would I do that?

Field: Amount To Order: [ReorderLevel]-[UnitsInStock]
Nov 14 '14 #1

✓ answered by Seth Schrock

If you are doing this in a query, then the field would look like this:
Expand|Select|Wrap|Line Numbers
  1. IIF(ReorderLevel-UnitsInStock<0, 0, ReorderLevel-UnitsInStock) As [Amount To Order]

4 3201
Seth Schrock
2,965 Expert 2GB
I would use the IIF() function to test if the returned value was less than 0. If true, then 0. Otherwise, return the value of the equation.
Nov 15 '14 #2
ThePie
3
What would a function like that look like? The column that it is in is a field that I just created, Amount To Order, will that cause any issues?
Nov 15 '14 #3
Seth Schrock
2,965 Expert 2GB
If you are doing this in a query, then the field would look like this:
Expand|Select|Wrap|Line Numbers
  1. IIF(ReorderLevel-UnitsInStock<0, 0, ReorderLevel-UnitsInStock) As [Amount To Order]
Nov 15 '14 #4
ThePie
3
Thank you Seth, the expression
Expand|Select|Wrap|Line Numbers
  1. Amount To Order: IIf([ReorderLevel]-[UnitsInStock]<0,0,[ReorderLevel]-[UnitsInStock])
worked like a charm.
Nov 16 '14 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

25
by: Jason | last post by:
Hi, below is example code which demonstrates a problem I have encountered. When passing a number to a function I compare it with a string's size and then take certain actions, unfortunately during...
16
by: JKop | last post by:
Take a class like the following: class Finger { public: double length; }
7
by: hasanainf | last post by:
Hi all, I have two querys QueryPurchased ProductID Location TotPcs Prod1 Loc1 100 Prod2 Loc1 50 Prod3 Loc1 150 Prod3 Loc3 150
5
by: Subrahmanyam Arya | last post by:
Hi Folks , I am trying to solve the problem of reading the numbers correctly from a serial line into an intel pentium processor machine . I am reading 1 byte and 2byte data both positive...
1
by: Wayne | last post by:
There is probably a simple solution to this but: I have a textbox that is bound to a number field in a table. The field type is "double". If I enter a negative value directly into the table it...
20
by: Casey | last post by:
Is there an easy way to use getopt and still allow negative numbers as args? I can easily write a workaround (pre-process the tail end of the arguments, stripping off any non-options including...
5
by: wilboy | last post by:
Hi everyone I have a small problem here. I only want return positive number or zero when - . Eg. - = 48.50 - 52.60 = 0 78.20 ...
3
by: Peng Yu | last post by:
Hi, I don't understand why rbegin() -rend() gives a negative number. Since rbegin() + 1 gives the one before the last element, I think rbegin() - rend() should give a positive number. ...
1
by: santoshsri | last post by:
Hi All, My C# web application calls a webservice to process a report. It sends XMLs as parameter and in response gets an XML node which stores Binay datatype bin.base64. It makes an instance of...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.