FrozenColumns Property

Applies To

Form, Query, Table.

Description

You can use the FrozenColumns property to determine how many columns in a datasheet are frozen. Frozen columns are displayed on the left side of the datasheet and don’t move when you scroll horizontally through the datasheet.

Note The FrozenColumns property applies only to tables, forms, and queries in Datasheet view.

Setting

The FrozenColumns property is set by Microsoft Access when you click Freeze Columns on the Format menu.

In Visual Basic, this property setting is an Integer indicating the number of columns in the datasheet that have been frozen using the Freeze Columns command. The record selector column is always frozen, so the default value is 1. Consequently, if you freeze one column, the FrozenColumns property is set to 2; if you freeze two columns, it’s set to 3; and so on.

This property setting is read-only in all views.

Remarks

When you freeze columns using the Freeze Columns command, Microsoft Access automatically moves the columns to the leftmost edge of the datasheet in the order in which you froze them. For example, if you freeze three columns, these become the first, second, and third columns in the datasheet. Because the record selector column is always frozen, the FrozenColumns property in this case will be set to 4. The three columns you freeze will have their ColumnOrder properties set to 1, 2, and 3 (in the order they are frozen).

If you click Unfreeze All Columns on the Format menu, all frozen columns will be unfrozen, and the FrozenColumns property will be set to 1.

Example

The following example uses the FrozenColumns property to determine how many columns are frozen in a table in Datasheet view. If more than three columns are frozen, the table size is maximized so you can see as many unfrozen columns as possible.


Sub CheckFrozen(tblName As String)
    Dim db As Database
    Dim td As TableDef
    Dim prop As Property
    conPropertyNotFound = 3270        ' Property not found error.
    Set db = CurrentDb        ' Get current database.
    Set td = db.TableDefs(tblName)        ' Get object for table.
    DoCmd.OpenTable tblName, acNormal        ' Open table.
    td.Properties.Refresh
    On Error GoTo Frozen_Err
    If td.Properties("FrozenColumns") > 3 Then     ' Check property.
        DoCmd.Maximize
    End If_Bye:
    Exit Sub_Err:
    If Err = conPropertyNotFound Then    ' Property not in collection.
        Set prop = td.CreateProperty("FrozenColumns", dbInteger, 1)
        td.Properties.Append prop
        Resume Frozen_Bye
    End IfSub