Ottiene il minimo valore di un campo
Funzione Visual Basic per ottenere il minimo valore da una tabella (o query) Access.
Public Function getMinValue(table, neededField, whereCondition)
'legge un valore da una tabella db.
Dim myDb As Database
Set myDb = CurrentDb()
Dim sSql As String
Dim rsgetMinValue As Recordset
sSql = " SELECT * FROM " & table
Set rsgetMinValue = myDb.OpenRecordset(sSql)
If rsgetMinValue.RecordCount = 0 Then
getMinValue = 0
Else
rsgetMinValue.Close
sSql = " SELECT '0'& MIN(" & neededField & ") AS MINIMO FROM " & table & " WHERE " & whereCondition
'MsgBox sSql
Set rsgetMinValue = myDb.OpenRecordset(sSql)
getMinValue = rsgetMinValue("MINIMO")
End If
rsgetMinValue.Close
Set rsgetMinValue = Nothing
End Function
tags: vba visual basic macro access min minimo
I want to drink a coffee :-)
Sponsored Links
Inserisci nel tuo sito il modulo di ricerca Google di LifeInRete.it! Copia il seguente modulo: