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


Ricerca


Ultimi Contenuti Inseriti

How to add onload property to masterpage from child
HtmlGenericControl body = (HtmlGeneric...

C# ASP.NET
...

Transpose Column to row
create table #temp (timeId int, dim1Id int, dim2I...

SQL Server
...

(X) HTML
Suggerimenti ed esempi riguardanti il linguaggio H...

Sponsor