Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple function

Status
Not open for further replies.

JamesBollard

Technical User
Joined
Aug 6, 2001
Messages
3
Location
GB
Hi

I'm new to access vba but I need to write a function to find the highest value in a field. Anyone know what this would be? Help much appreciated.

Cheers

James
 
Code:
Function GetMax(array() as ...) as long
Dim lngMax as long
Dim I as long

lngMax = array(0)
For I = 1 to Ubound(array)
    if array(I) > lngMax) then
        lngMax = array(I)
    End if
Next
GetMax = lngMax
 
If it is a 'field' in a table, just use an aggregate query, with the field and the (SQL) function MAX.

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top