MaximumValue Property

Microsoft FrontPage Visual Basic

MaximumValue Property

Returns or sets a Variant that specifies the maximum value allowed for this field. This property is the equivalent of setting the Maximum value allowed field in the Modify Field dialog box of the user interface. Read/write.

expression.MaximumValue

expression    Required. An expression that returns one of the objects in the Applies To list.

Remarks

An error message will be displayed to the user if invalid data is entered into this field. Use the MinimumValue property value to set the minimum value for the field.

Example

The following example displays the names and maximum values of all fields of type fpFieldNumber and fpFieldCurrency in the first list of the active Web site. If the list contains no fields of this type, a message is displayed to the user.

    Sub DisplayMaximum()
'Displays the maximum value of all ListFieldNumber
'and ListFieldCurrency fields in the list

    Dim objApp As FrontPage.Application
    Dim objLstFlds As ListFields
    Dim strName As String
    Dim objLstFld As Object
    Dim strValues As String

    Set objApp = FrontPage.Application
    Set objLstFlds = objApp.ActiveWeb.Lists.Item(0).Fields
    'Cycle through lists and add value to string
    For Each objLstFld In objLstFlds
        If (objLstFld.Type = fpFieldNumber) Or (objLstFld.Type = fpFieldCurrency) Then
            strValues = strValues & objLstFld.Name & vbTab & _
                        objLstFld.MaximumValue & vbCr
        End If
    Next objLstFld

    If strValues <> "" Then
        MsgBox "The fields and their maximum values are:" & vbCr & _
                vbCr & strValues
    Else
        MsgBox "There are no ListFieldNumber or ListFieldCurrency fields in the current list."
    End If

End Sub
  

The following example changes the maximum value of all fields of type ListFieldNumber in the first list of the active Web site to a constant with the value 200.

Note  Use the ApplyChanges method to apply any changes made to the list.

    Sub ChangeMaximum()
'Changes maximum value for all fields of type
'ListFieldNumber

    Dim objApp As FrontPage.Application
    Dim objLstFlds As ListFields
    Dim strName As String
    Dim objLstFld As Object
    Const varMax As Variant = 200

    Set objApp = FrontPage.Application
    If objApp.ActiveWeb.Lists.Count > 0 Then
        Set objLstFlds = objApp.ActiveWeb.Lists.Item(0).Fields
        'Cycle through lists and change values
        For Each objLstFld In objLstFlds
            If objLstFld.Type = fpFieldNumber Then
                objLstFld.MaximumValue = varMax
            End If
        Next objLstFld
        objApp.ActiveWeb.Lists(0).ApplyChanges
    Else
        MsgBox "The active Web site contains no lists."
    End If
End Sub