Calling Functions

B

Bruce D.

I am using Access 2003. I am trying to create a report using a Min function
for array values. The function is suppose to return the min value of the
array. This is a little beyond my experience. But how would I call that
function in my report? I have a total field that I would need to have this
execute in. Here is the code I am using.
Thanks for all who reply !!!

BD


Public Function fArrayMin(varArray As Variant) As Variant
Dim varitem As Variant
Dim varmin As Variant
Dim i As Long
On Error GoTo dhArrayMin_Error
If IsArray(varArray) Then
If UBound(varArray) = -1 Then
fArrayMin = Null
Else
varmin = varArray(LBound(varArray))
For i = LBound(varArray) To UBound(varArray)
varitem = varArray(i)
If varitem < varmin Then
varmin = varitem
End If
Next i
fArrayMin = varmin
End If
Else
fArrayMin = varArray
End If

On Error GoTo 0
Exit Function
dhArrayMin_Error:

MsgBox "Error " & Err.Number & "(" & Err.description & ") in
procedure dhArrayMin of Module modTest"


End Function
 
D

Douglas J. Steele

Dim varMinimum As Variant

varMinimum = fArrayMin(MyArray)

where MyArray is any array.
 
L

Larry Daugherty

Hi Bruce,

You'd actually do what you want in the Query on which the Report is based.
With the report in design mode, Look in its Properties for its data source.
Create a query using the QBE grid It gives you lots of tools to shape your
data for the report.

HTH
 
Top