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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

finding the minimum value from multiple fields in one record 1

Status
Not open for further replies.

jamwat

Technical User
Jul 8, 2005
10
0
0
AU
hi

i am trying to get the minimum value from 7 fields of 1 record in form view and struggling to get the expression right

can you help
 
In a standard code module create this function:
Code:
'A generic function to get the min value of an arbirtrary numbers of same type values:
Public Function MyMin(ParamArray Args())
Dim i As Long, rv
If UBound(Args) >= 0 Then rv = Args(LBound(Args))
For i = 1 + LBound(Args) To UBound(Args)
  If IsNull(rv) Or rv > Args(i) Then rv = Args(i)
Next
MyMin = rv
End Function

Example of use:
minOf7 = MyMin([field1], [field2], ..., [field7])

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
hi phv

i have tried to use the information you sent but havn't made it work

when i try to select multiple fields in the expression builder and separate them by coma's the function fails

if i knew how to do do the above i would be fine

to be honest i am not very good with vba and couldn't fully understand the code you sent

many thanks for you're help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top