MS Access

Changing a Control's Data Source

Examples of bound, unbound, and calculated controls
Setting the Control Source property
The steps in modifying a control's text label.

There are three types of controls that you can add to your forms, as illustrated in Figure. They are:

  • Bound Controls: Bound controls are bound or connected to an underlying field in a table or query. You use to display, enter, and update field values in your database. The fields that you can add to a form using the Field List are all examples of .

  • Unbound Controls: Unbound controls are not bound or connected to an underlying field in a table or query. You use to display information. Labels, text boxes, and buttons can all be inserted on a form as . The two check boxes you added to the form in the previous lessons are both examples of unbound controls because they aren't connected to an underlying field in a table or query.

  • Calculated Controls: Calculated controls are based on an expression and are used to calculate values in a form, such as arithmetic problems. Technically, are unbound controls because they do not update any table fields.

A control's Control Source property determines what is displayed in a control here's how:

  • A bound control's Control Source property contains the name of the underlying database field to which it is bound.

  • An unbound control's Control Source property does not contain the name of an underlying database field.

  • A calculated control's Control Source property contains an expression that calculates the values displayed in the control.

This lesson explains how you can change a control's Control Source property.

  1. Select the first check box control you added in the previous lesson, and display its properties by clicking the Properties button on the Form Design toolbar.

    The Properties dialog box appears. You can find the Control Source property on the Data Tab.

  2. Click the Data tab.

    The Data tab appears, as shown in figure. You can determine what is displayed in the control by setting the Control Source property. You can bind the control to a field in the form's underlying query or table by clicking the button, or you can type text or an expression directly into the Control Source box. We want to bind the selected check box to the Smoker field.

  3. Click in the Control Source box, click the button, and select Smoker from the list, as shown in figure.

    The check box is now bound to the Smoker field in the tblCustomers table. Next let's bind the other check box control you added to the First Class field.

  4. With the Properties dialog box still open, click the second check box control you added in the previous lesson.

    The Properties dialog box is updated and displays the settings for the selected check box control.

  5. Click in the Control Source box, click the button, and select First Class from the list.

    You're done specifying the data sources for the two check boxes so you can close the Properties dialog box.

  6. Click the Close button to close the Properties dialog box.

    Before we're finished, we have to give the two check boxes more meaningful text labels. Here's how:

  7. Position the pointer over the first check box text label, until it changes into a , and then click inside the text label, as illustrated in figure.

    Now you can edit the check box text label.

  8. Replace the text label text with Smoker.

    Now move on to the next step and change the text label for the second check box.

  9. Following the same procedures as Steps 7-8, rename the second check box text label First Class.

    That's it! You're done binding the check boxes to two underlying database fields.

  10. Click on the Close button to close the frmCustomers form and click Yes to save your changes.

TO CHANGE A CONTROL'S DATA SOURCE:

  1. DISPLAY THE FORM IN DESIGN VIEW.

  2. SELECT THE CONTROL AND CLICK THE PROPERTIES BUTTON ON THE TOOLBAR.

    OR...

    RIGHT-CLICK THE CONTROL AND SELECT PROPERTIES FROM THE SHORTCUT MENU.

    OR...

    SELECT THE CONTROL AND SELECT VIEW » PROPERTIES FROM THE MENU.

  3. CLICK THE DATA TAB.

  4. CLICK THE CONTROL SOURCE BOX, CLICK THE ARROW, AND SELECT THE FIELD THAT YOU WANT TO BIND THE CONTROL TO.

    OR...

    CLICK THE CONTROL SOURCE BOX AND ENTER AN EXPRESSION.

  5. CLOSE THE PROPERTIES DIALOG BOX.