If Else Qstn??

G

Guest

Hi,
I have calculated field LineTotal in a query that is based on the result of
the multiplication between 3 fields in the same table ie
[Qty]*[Weight]*[UnitPrice]=[LineTotal]
But the simple problem is the weight is either Null or Zero sometimes thus
making LineTotal end up being zero or null.
Therefore I would really like someone to help me out on getting the right
calculation statement for LineTotal... something in the line of the statement
below if you know what I mean.

If Not IsNull(Me!Weight) > 0 Then
Me.LineTotal = Me.PackQty * Me.Weight * Me.UnitPrice
Else
Me.LineTotal = Me.UnitPrice * Me.PackQty
End If

Thanks in advance
 
F

fredg

Hi,
I have calculated field LineTotal in a query that is based on the result of
the multiplication between 3 fields in the same table ie
[Qty]*[Weight]*[UnitPrice]=[LineTotal]
But the simple problem is the weight is either Null or Zero sometimes thus
making LineTotal end up being zero or null.
Therefore I would really like someone to help me out on getting the right
calculation statement for LineTotal... something in the line of the statement
below if you know what I mean.

If Not IsNull(Me!Weight) > 0 Then
Me.LineTotal = Me.PackQty * Me.Weight * Me.UnitPrice
Else
Me.LineTotal = Me.UnitPrice * Me.PackQty
End If

Thanks in advance

In a query?

LineTotal:IIf(IsNull([Weight]) or [Weight] = 0,[UnitPrice] *
[PackQty], [PackQty] * [Weight] * [UnitPrice])
 
G

Guest

Yes in a Query...
That is what I got for a LineTotal field at the moment...
Line Total:
nz([tblOrderDetails.UnitPrice],0)*nz([PackQty],0)*nz([Weight],1)*nz([Counts],1)
--
niuginikiwi
Nelson, New Zealand


fredg said:
Hi,
I have calculated field LineTotal in a query that is based on the result of
the multiplication between 3 fields in the same table ie
[Qty]*[Weight]*[UnitPrice]=[LineTotal]
But the simple problem is the weight is either Null or Zero sometimes thus
making LineTotal end up being zero or null.
Therefore I would really like someone to help me out on getting the right
calculation statement for LineTotal... something in the line of the statement
below if you know what I mean.

If Not IsNull(Me!Weight) > 0 Then
Me.LineTotal = Me.PackQty * Me.Weight * Me.UnitPrice
Else
Me.LineTotal = Me.UnitPrice * Me.PackQty
End If

Thanks in advance

In a query?

LineTotal:IIf(IsNull([Weight]) or [Weight] = 0,[UnitPrice] *
[PackQty], [PackQty] * [Weight] * [UnitPrice])
 
J

John Spencer

Well, you have handled Nulls, but not zeroes. Also, your posting has
invalid bracketing around tblOrderDetails.UnitPrice

Nz([tblOrderDetails].[UnitPrice],0) * IIF(NZ(Weight,0)=0,1,Weight) *
Nz(PackQty,0) * Nz([Counts],1)

I'm not sure that will fix the problem in your calculation, since if you
will still get zeroes if any of the other fields in the calculation are
zero, but that can be taken care of by using the same logic as is used for
Weight. It depends on what you want the calculation to return.


niuginikiwi said:
Yes in a Query...
That is what I got for a LineTotal field at the moment...
Line Total:
nz([tblOrderDetails.UnitPrice],0)*nz([PackQty],0)*nz([Weight],1)*nz([Counts],1)
--
niuginikiwi
Nelson, New Zealand


fredg said:
Hi,
I have calculated field LineTotal in a query that is based on the
result of
the multiplication between 3 fields in the same table ie
[Qty]*[Weight]*[UnitPrice]=[LineTotal]
But the simple problem is the weight is either Null or Zero sometimes
thus
making LineTotal end up being zero or null.
Therefore I would really like someone to help me out on getting the
right
calculation statement for LineTotal... something in the line of the
statement
below if you know what I mean.

If Not IsNull(Me!Weight) > 0 Then
Me.LineTotal = Me.PackQty * Me.Weight * Me.UnitPrice
Else
Me.LineTotal = Me.UnitPrice * Me.PackQty
End If

Thanks in advance

In a query?

LineTotal:IIf(IsNull([Weight]) or [Weight] = 0,[UnitPrice] *
[PackQty], [PackQty] * [Weight] * [UnitPrice])
 

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