CasewareDocs

MinMaxValue

Calculates the min. and max. value of a field. Only valid for numeric and date fields.

Compatibility

Available as of IDEA version 9.0

Syntax

MinMaxValue(database as Object, fieldName as String)

Parameters

database

Object containing the opened database.

fieldName

String name of the field for which the min. and max. values are to be calculated.

Remarks

MinMaxValue is only supported for numeric and date fields, not for character and time fields.

Regional setting does not affect the result.

Example

Dim SimpleCommands As Object 
'Object containing min. and max. values depending on fieldName.
Dim MinMaxAs Object
Dim db As Object
Dim SourceName As String
Dim MinNum As Double
Dim MaxNum As Double
Dim MinDate As Date
Dim MaxDate As Date

Sub Main
Set SimpleCommands = SmartContext.MacroCommands.SimpleCommands

'Get the name of the database.
SourceName = SmartContext.PrimaryInputFile

'Open the database.
Set db = Client.OpenDatabase(SourceName)
'Calculate min. and max. values for numeric field "AMOUNT" in table SourceName.
Set MinMax = SimpleCommands.MinMaxValue(db, "AMOUNT")
MinNum = MinMax.MinNum
MaxNum = MinMax.MaxNum
'Calculate min. and max. values for date field "DUE_DATE" in database SourceName.
Set MinMax = SimpleCommands.MinMaxValue(db, "DUE_DATE")
MinDate = MinMax.MinDate
MaxDate = MinMax.MaxDate

'Close the database.
db.Close
Set db = Nothing

'Release objects.
Set MinMax = Nothing
Set SimpleCommands = Nothing
End Sub
MinMaxValue | Caseware Docs