Home

Windows Controls: The Check Box

 

Description

You can create a Boolean field on a form. One option is to create a field that is linked to a column of a table. The easiest way to do that, after displaying the form in Design View and clicking the Add Existing Fields from the Ribbon, from the Field List, drag the Boolean-based column and drop it on the form.

Whether linking it to a column of a table or not, you can add a check box to a form. To do that, after displaying the form in Design View, in the Controls section of the Ribbon, click the Check Box Check Box and click the form. You can then use the control as a normal Microsoft Windows object. If you want to link it to a column of a table, in its Properties window, set its Control Source to that column. You can also add a combo box to a form and set its Record Source property to a Boolean-based field.

To programmatically create a check box, call the CreateControl() method and pass the second argument as acCheckBox. Here is an example:

Private Sub cmdCreateControl_Click()
    Dim ctlIsMarried As Control
    
    Set ctlIsMarried = CreateControl("Exercise", acCheckBox)

    Set ctlIsMarried = Nothing
End Sub

If you want the check box to be linked to a column of a table, pass the name of the table as the fourth argument and the name of the column as the fifth argument. Here is an example:

Private Sub cmdCreateControl_Click()
    Dim ctlIsMarried As Control
    
    Set ctlIsMarried = CreateControl("Fundamentals", _
                                    AcControlType.acCheckBox, _
                                    acSection.acDetail, _
                                    "[Student Registration]", _
                                    "[Full Time Student]", _
                                    840, 300)

    Set ctlIsMarried = Nothing
End Sub

 

 

 

 

   

 

Home Copyright © 2009-2016, FunctionX, Inc.