Calling Functions

G

Guest

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
 

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

Similar Threads

Comparing data 1
Invalid Use of Null 3
Array Coding Conversion to 2010 0
update db, no errors , no changes 6
Returning full contents of an array to excel 3
PLEASE HELP, insert 1
insert problems 1
Array to String 9

Top