Positive Integers Only

E

ExcessAccess

I have a make-table query. One of the fields that this
query makes is called "Quantity." It's a calculated field
that creates a number. I only want positive integers. As
of now, I get numbers like 6489.498 or -210. How can I
make it so that all negative numbers become "0"? How can
I also make it so that I only get whole numbers, with no
numbers to the right of the decimal?

Thanks much in advance.

~J
 
M

May

Try this way
iif([fieldname]<0,0,cint([fieldname]))

May
MCP in Access and SQL Server
 
D

Duane Hookom

Use a calculated expression like:
NewField: IIf([expression]<0,0,Int([expression]))
 
E

ExcessAccess

When I use your suggested expression in the criteria for
the calclated field, it changes the total number of
records showing up after running the query (make-table).
Can you tell me why this is happening?

~J

-----Original Message-----
Use a calculated expression like:
NewField: IIf([expression]<0,0,Int([expression]))


--
Duane Hookom
MS Access MVP


ExcessAccess said:
I have a make-table query. One of the fields that this
query makes is called "Quantity." It's a calculated field
that creates a number. I only want positive integers. As
of now, I get numbers like 6489.498 or -210. How can I
make it so that all negative numbers become "0"? How can
I also make it so that I only get whole numbers, with no
numbers to the right of the decimal?

Thanks much in advance.

~J


.
 
D

Duane Hookom

I didn't expect you to place anything in the criteria. This is the "Field"
expression in the first line of the query grid.

--
Duane Hookom
MS Access MVP


ExcessAccess said:
When I use your suggested expression in the criteria for
the calclated field, it changes the total number of
records showing up after running the query (make-table).
Can you tell me why this is happening?

~J

-----Original Message-----
Use a calculated expression like:
NewField: IIf([expression]<0,0,Int([expression]))


--
Duane Hookom
MS Access MVP


ExcessAccess said:
I have a make-table query. One of the fields that this
query makes is called "Quantity." It's a calculated field
that creates a number. I only want positive integers. As
of now, I get numbers like 6489.498 or -210. How can I
make it so that all negative numbers become "0"? How can
I also make it so that I only get whole numbers, with no
numbers to the right of the decimal?

Thanks much in advance.

~J


.
 

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