Report Calcuation

G

Guest

Hi everyone,
I need to create a field in a report that will have a control source of
which is the lowest price between [price1],[price2],[price3]. I would also
have to allow for null or zero values. Thanks for any info.

Bruce D.
 
T

Tom Collins\(Home\)

| Hi everyone,
| I need to create a field in a report that will have a control source
of
| which is the lowest price between [price1],[price2],[price3]. I
would also
| have to allow for null or zero values. Thanks for any info.
|
| Bruce D.
|

You need a function within a module to do this. Try this:

Function MinPrice(ParamArray Price()) As Currency
Dim TempPrice
Dim I As Integer
TempPrice = Nz(Price(0), 0)
For I = 1 To UBound(Price)
Price(I) = Nz(Price(I), 0)
If Price(I) < TempPrice Then
TempPrice = Price(I)
End If
Next I
MinPrice = CCur(TempPrice)
End Function

This will accept as many variables you want. It will assume Nulls are
zero. Change the Currency to whatever datatype you need.
Call this with =MinPrice([price1],[price2],[price3])

Tom Collins
 

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