Share via


Value Property [Access 2003 VBA Language Reference]

You can use the Value property to determine or specify if a control is selected, the selected value or option within the control, the text contained in a text box control, or the value of a custom property.

  • Check box, option button, and toggle button controls. Determines or specifies whether or not the control is selected.

  • Combo box, list box, and option group controls. Determines or specifies which value or option in the control is selected.

  • Text box controls. Determines or specifies the text in the text box.

  • Tab control. Determines or specifies the selected Page object.

  • Built-in properties. Determines or specifies the value of a built-in property of an AccessObject object.

Read/write Variant.

expression.Value

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

Remarks

The Value property uses the following setting depending on the specified control.

Control Setting Description Visual Basic
Check box True

False

The check box is selected.

(Default) The check box is cleared.

True

False

Combo box [The text in the text box portion of the control] This may or may not be the same as the setting for the Text property of the control. The current setting for the Text property is what is displayed in the text box portion of the combo box; the Value property is set to the Text property setting only after this text is saved.
List box [The list box item value] The value in the bound column for the item selected in the list.
Option button True

False

The option button is selected.

(Default) The option button isn't selected.

True

False

Option group [The OptionValue property setting] The OptionValue property setting for the selected control in the group.
Text box [The value of the control's Text property] The Text property returns the formatted string. The Text property may be different than the Value property for a text box control. The Text property is the current contents of the control. The Value property is the saved value of the text box control. The Text property is always current while the control has the focus.
Toggle button True

False

The toggle button is pressed in.

The toggle button isn't pressed in.

True

False

Tab control [An Integer value representing the index number of the currently selected Page object] The Value property of a tab control contains the index number of the current Page object. There is one Page object for each tab in a tab control. The first Page object always has an index number of 0, the second has an index number of 1, and so on.
Bound object frame or chart control The Value property for a bound object frame or a bound chart control is set to the value of the field that the control is bound to. Since these fields normally contain OLE objects or chart objects, which are stored as binary data, this value is usually meaningless.
ActiveX control Some ActiveX controls support the Value property. For example, the Value property setting for a Calendar control is the currently selected date in the control. For more information, see the documentation for each ActiveX control.
Custom properties A Long or string expression representing the value of the custom property. The Value property of a custom property contains the value of the specified custom property of an AccessObject object. For more information about custom properties, see the topics about the AccessObject object, AccessObjectProperty object, and the AccessObjectProperties collection.

Note  You can set this property by using a macro or Visual Basic .

  • The Value property returns or sets a control's default property, which is the property that is assumed when you don't explicitly specify a property name. In the following example, because the default value of the text box is the value of the Text property, you can refer to its Text property setting without explicitly specifying the name of the property.

    Forms!frmCustomers!txtLastName = "Smith"
    

This means that the following two statements are equivalent.

Forms!frmCustomers!optCreditApproved.Value = True

Forms!frmCustomers!optCreditApproved = True

Note   The Value property is not the same as the DefaultValue property, which specifies the value that a property is assigned when a new record is created.

  • The Value property can also return or set a custom properties' default property, which is the property that is assumed when you don't explicitly specify a property name.This means that the following two statements are equivalent.
CurrentProject.AllForms!optCreditApproved.Value = True

CurrentProject.AllForms!optCreditApproved = True

Example

The following example shows how you can call one of two procedures, depending whether the Credit check box on the Customers form is selected or cleared.

Sub PaymentType()
    If Forms!Customers!Credit.Value = False Then
        ProcessCash
    ElseIf Forms!Customers!Credit.Value = True Then
        ProcessCredit
    End If
End Sub

Applies to | AccessObjectProperty Object | BoundObjectFrame Object | CheckBox Object | ComboBox Object | CustomControl Object | ListBox Object | OptionButton Object | OptionGroup Object | SmartTagProperty Object | TabControl Collection | TextBox Object | ToggleButton Object

See Also | DefaultValue Property | OldValue Property | OptionValue Property | Text Property