Share via


Visual Basic Concepts

Field Mapping

One of the features of the Data Environment is that it allows you to drag fields from the Data Environment onto a form or report. When you are designing a Data Environment, you can specify what control is created when the field is dropped based on the data type of the field. For example, you can have a Spin Edit Control created for all integer types. You can also specify a specific control on a per-field basis.

There are three levels of controls that you can specify. When a field is dropped onto a form, the Data Environment looks for a control in the order described in the following table. The first level that has a control associated with it is used.

Control Level Description
Field Object Within a DataEnvironment object, a control can be directly associated with a Field object in a Command object. The control is specified as a property of the Field object and is only applicable to that specific field.

If no control is specified for the dropped Field object, the Data Environment moves to the next level: ADO Data Type.

ADO Data Type A control can be associated with a specific ADO data type. For example, a control can be associated with the ADO data type adTinyInt. Thus, whenever a field of this type is dropped on the form (and it does not have a control associated with the Field object), the control associated with the ADO data type is created.

Note   These settings will affect all DataEnvironment objects on your system.

If no control is associated with the specific ADO data type, the Data Environment moves to the next level: Field Type Categories.

Field Type Categories Since there are a large number of ADO data types that store similar data, a set of Field Type categories are defined. For example, all integer-related data types (such as adBigInt, adTinyInt, and so forth) are combined into a Field Type category of Integer. If no control is associated with the specific ADO data type, the control associated with the Field Type that contains the ADO data type is used.

If there is no control associated with the Field Type category, the system defaults to an intrinsic TextBox control.

There are two special Field Type categories: Caption and Multiple. The control associated with Caption is the control used when a label object is created next to a new control. The control associated with Multiple appears when you complete a right-drag of a Command object, and is typically used to specify a grid control.

The following procedures describe how to set field mapping information for your drag and drop controls.

To change the Caption control for a single Field object

  1. Right-click a Field object and click Properties on the shortcut menu.

  2. In the Field Mapping frame, set the Control and the Caption.

  3. Click OK to set the field mapping properties for the current Field object and close the dialog box.

To change the Caption control for more than one Field object at a time

  1. Select a Command object and click Options on the Data Environment designer toolbar.

    -or-

    Right-click your DataEnvironment object and click Options on the shortcut menu.

  2. From the Field Mapping tab of the Options dialog box, select Show All Data Types.

  3. Select each Field object from the Category/Field Type and Control list, and change its control in the Control box.

  4. Click OK to set the Caption control properties and close the dialog box.

To specify an ADO Data Type or Category control

  1. Select a Command object and click Options on the Data Environment designer toolbar.

    -or-

    Right-click your DataEnvironment object and click Options on the shortcut menu.

  2. On the Field Mapping tab of the Options dialog box, select Show all data types, and then specify the control:

Control Description
ADO Data Type Select a Data Type (for example, adBinary) from the Default Control Association list, and then associate it with a Control list item.
Category Select a Category (for example, Binary) from the Default Control Association list, and then associate it with a Control list item.
  1. Click OK to set the control properties and close the dialog box.

To prevent the creation of labels for Field objects

  1. Select a Command object and click Options on the Data Environment designer toolbar.

    -or-

    Right-click your DataEnvironment object and choose Options from the shortcut menu.

  2. On the Field Mapping tab of the Options dialog box, deselect Drag and Drop Field Captions. The Field object captions (labels) will not be created on a drag and drop function.

  3. Click OK to set the control properties and close the dialog box.