Results 1 to 7 of 7
Thread: Multiplying by 0 (Access 2000)

20050510, 04:17 #1
 Join Date
 Apr 2005
 Location
 Plovdiv
 Posts
 109
 Thanks
 0
 Thanked 0 Times in 0 Posts
Multiplying by 0 (Access 2000)
How to avoid the error in a query when one of the 2 fields has a 0 value?
My expression is
field1*field2/field1
However when the value of the field1 is say 0, i want to divide
field2/field1,that is to say to avoid the multiplication by 0, which gives 0

20050510, 05:19 #2
 Join Date
 Feb 2001
 Location
 Sint Niklaas, Belgium
 Posts
 2,778
 Thanks
 0
 Thanked 0 Times in 0 Posts
Re: Multiplying by 0 (Access 2000)
Are you sure about you expression ?
<hr>However when the value of the field1 is say 0, i want to divideIf field1 is 0 then you have a division by 0 and this will always give an error.
field2/field1<hr>Francois

20050510, 06:12 #3
 Join Date
 Mar 2002
 Posts
 84,353
 Thanks
 0
 Thanked 30 Times in 30 Posts
Re: Multiplying by 0 (Access 2000)
You seem to confuse multiplication and division.
Multiplication: 6 * 2 = 12
Division: 6 / 2 = 3
You can multiply by any number, including 0, for example 6 * 0 = 0
You can NOT divide by 0. If you try to calculate 6 / 0, you get an error.
What do you want to accomplish? Your expression isn't useful, field1*field2/field1 results in field2 unless field1 is 0.

20050510, 06:26 #4
 Join Date
 Apr 2005
 Location
 Plovdiv
 Posts
 109
 Thanks
 0
 Thanked 0 Times in 0 Posts
Re: Multiplying by 0 (Access 2000)
Please accept my apologies to both of you. I am really sorry to have muddled my expression.I have corrected it to read as follows
[field1]/[pack]+[field2]
Once again please excuse me for my mistake.
In my expression i want to round down the figures.Say if I have 4.98 want the number to round down to 4.
I tried with Int as
Int[field1]/[pack]+[field2]
But Acces didnt accept that.Any reason?

20050510, 06:32 #5
 Join Date
 Mar 2002
 Posts
 84,353
 Thanks
 0
 Thanked 30 Times in 30 Posts
Re: Multiplying by 0 (Access 2000)
Int is a function, its argument must be between parentheses ( and ). So try
Int([field1]/[pack]+[field2])

20050510, 06:52 #6
 Join Date
 Apr 2005
 Location
 Plovdiv
 Posts
 109
 Thanks
 0
 Thanked 0 Times in 0 Posts
Re: Multiplying by 0 (Access 2000)
Thank you, Hans ! I will try it.Just to mention another problem.I regret to find that my query with the calculated field [field1]/[pack]+[field2]
seems more difficult than i thought.The point is, that i must include a condition:
the expression should take place only when pack is less than 6, otherwise
i should only divide field1 to pack and not add field2.
Can i put it into the query ?

20050510, 06:58 #7
 Join Date
 Mar 2002
 Posts
 84,353
 Thanks
 0
 Thanked 30 Times in 30 Posts
Re: Multiplying by 0 (Access 2000)
Try
<code>
Int([field1]/[pack]+IIf([pack]<6,[field2],0))
</code>
The IIf function can be used to include conditional values within an expression.