So for you I've developped this function:
You introduce like a SQL parameter a query on which you would like to find the minimum between columns, also introduce the start column with numeric data to be compared and the end column! Between the columns you have to have only numeric fields that have to be compared!
The function returns only the first line! So in your SQL supply only one line!
:)
-
Function min_in_columns(SQL, Start_col, End_col) As Double
-
Dim mydb As Database
-
Dim myr As Recordset
-
Dim i
-
Dim min_value
-
-
Set mydb = CurrentDb()
-
Set myr = mydb.OpenRecordset(SQL)
-
-
min_value = 0
-
-
myr.MoveFirst
-
For i = Start_col To End_col
-
If min_value > myr(i) Then
-
min_value = myr(i)
-
End If
-
Next i
-
myr.Close
-
mydb.Close
-
-
min_in_columns = min_value
-
End Function
-
Is this a module? How shoud i use it
I have save it as 'module1' and in the calculated field of query table typed - Min: min_in_columns ([numer1], [number2], [number3])
but when i open the query, it opens the module automatically.
I do not know how to write module and how to refere the same in query to work it.
please help me. You are too intelegent to help me, i know it.