#Error in Query

J

J. Trucking

Hello,

I have a query with calculates production for a machine in terms of
tonnes/hr. A use will input the starting engine hours, starting
tonnes, ending engine hours, and ending tonnes for each day. I have
an expression in a query which will subtract the starting and ending
hours/tonnes and then divide by one another. This works great unless
maintenance was being done on the machine and no production was
acheived. You then get 0/0 which produces the #Error message. I
posted this question once and someone told be to write this for my
expression:

Expr1: IIf(IsError(([TonneEnd]-[TonneStart])/([EngineEnd]-
[EngineStart])),0,([TonneEnd]-[TonneStart])/([EngineEnd]-
[EngineStart]))

However, I still get the #Error message. Is there something else I
should switch or should I somehow change the message. I would like it
to display zero if there is no production.

Thanks in advance,

John
 
K

Ken Snell \(MVP\)

Try this:

Expr1:
IIf(([EngineEnd]-[EngineStart])=0,0,(([TonneEnd]-[TonneStart])/([EngineEnd]-[EngineStart])))
 
J

J. Trucking

Try this:

Expr1:
IIf(([EngineEnd]-[EngineStart])=0,0,(([TonneEnd]-[TonneStart])/([EngineEnd]­-[EngineStart])))

--

Ken Snell
<MS ACCESS MVP>




I have a query with calculates production for a machine in terms of
tonnes/hr. A use will input the starting engine hours, starting
tonnes, ending engine hours, and ending tonnes for each day. I have
an expression in a query which will subtract the starting and ending
hours/tonnes and then divide by one another. This works great unless
maintenance was being done on the machine and no production was
acheived. You then get 0/0 which produces the #Error message. I
posted this question once and someone told be to write this for my
expression:
Expr1: IIf(IsError(([TonneEnd]-[TonneStart])/([EngineEnd]-
[EngineStart])),0,([TonneEnd]-[TonneStart])/([EngineEnd]-
[EngineStart]))
However, I still get the #Error message. Is there something else I
should switch or should I somehow change the message. I would like it
to display zero if there is no production.
Thanks in advance,
John- Hide quoted text -

- Show quoted text -

Thanks Ken,

Worked great.
 

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