About types of controls in Access

Microsoft Access includes the following types of controls, which are all accessible through the toolbox (toolbox: A set of tools that is available in Design view for adding controls to a form or report.) in Design view (Design view: A view that shows the design of these database objects: tables, queries, forms, reports, and macros. In Design view, you can create new database objects and modify the design of existing objects.) of a form, report, or data access page: text box, label, option group, option button, check box, list box, command button, tab control, image control, line, rectangle, and ActiveX custom controls. You can also add a Microsoft Office PivotTable list, an Office Chart, or an Office Spreadsheet to a form, report, or data access page (data access page: A Web page, published from Access, that has a connection to a database. In a data access page, you can view, add to, edit, and manipulate the data stored in the database. A page can also include data from other sources, such as Excel.).

Forms and reports have these additional controls: toggle button, combo box, bound object frame, unbound object frame, and page break. You can also add a subform or subreport to a form or report. Data access pages also include the drop-down list box, hyperlinks, scrolling text, and the PivotTable list, spreadsheet, and chart components.

Controls are objects on a form, report, or data access page that display data, perform actions, or are used for decoration. For example, you can use a text box on a form, report, or data access page to display data, a command button on a form to open another form or report, or a line or rectangle to separate and group controls to make them more readable.

All the information on a form or report is contained in controls. On data access pages, information is contained in controls in the same way as it is on forms and reports. However, information can also be typed directly on the data access page.

Controls that you can use to display, enter, filter, or organize data in Access

ShowText boxes

You use text boxes on a form, report, or data access page (data access page: A Web page, published from Access, that has a connection to a database. In a data access page, you can view, add to, edit, and manipulate the data stored in the database. A page can also include data from other sources, such as Excel.) to display data from a record source (record source: The underlying source of data for a form, report, or data access page. In an Access database, it could be a table, query, or SQL statement. In an Access project, it could be a table, view, SQL statement, or stored procedure.). This type of text box is called a bound text box because it's bound to data in a field. Text boxes can also be unbound. For example, you can create an unbound text box to display the results of a calculation or to accept input from a user. Data in an unbound text box isn't stored anywhere.

Examples of bound and unbound text boxes

Callout 1 These bound text boxes display data from the ProductName and UnitPrice fields in the Products table.

Callout 2 This unbound text box displays the result of a calculation.

ShowLabels

You use labels on a form, report, or data access page (data access page: A Web page, published from Access, that has a connection to a database. In a data access page, you can view, add to, edit, and manipulate the data stored in the database. A page can also include data from other sources, such as Excel.) to display descriptive text such as titles, captions, or brief instructions. Labels don't display values from fields (field: An element of a table that contains a specific item of information, such as a last name. A Title field might contain Mr. or Ms. Databases such as Microsoft SQL Server refer to fields as columns.) or expressions (expression: Any combination of mathematical or logical operators, constants, functions, and names of fields, controls, and properties that evaluates to a single value. Expressions can perform calculations, manipulate characters, or test data.); they're always unbound (unbound control: A control that is not connected to a field in an underlying table, query, or SQL statement. An unbound control is often used to display informational text or decorative pictures.) and they don't change as you move from record to record.

A label can be attached to another control (control: A graphical user interface object, such as a text box, check box, scroll bar, or command button, that lets users control the program. You use controls to display data or choices, perform an action, or make the user interface easier to read.). When you create a text box, for example, it has an attached label that displays a caption for that text box. This label appears as a column heading in the Datasheet view (Datasheet view: A view that displays data from a table, form, query, view, or stored procedure in a row-and-column format. In Datasheet view, you can edit fields, add and delete data, and search for data.) of a form. When you create a label by using the Label tool Label control, the label stands on its own — it isn't attached to any other control. You use stand-alone labels for information such as the title of a form, report, or data access page, or for other descriptive text. Stand-alone labels don't appear in Datasheet view.

Labels are either stand-alone or attached to a control

Callout 1 Stand-alone label

Callout 2 Labels attached to text boxes

ShowList boxes, combo boxes and drop-down list boxes

In many cases, it's quicker and easier to select a value from a list than to remember a value to type. A list of choices also helps to ensure that the value that's entered in a field is correct. If you have enough room on your form or data access page (data access page: A Web page, published from Access, that has a connection to a database. In a data access page, you can view, add to, edit, and manipulate the data stored in the database. A page can also include data from other sources, such as Excel.) to display the list at all times, you might want to use a list box. When you want to create a control that displays a list but requires less room, use a combo box (combo box: A control used on a form that provides the combined functionality of a list box and a text box. You can type a value in a combo box, or you can click the control to display a list and then select an item from that list.) if you are working in a form, or use a drop-down list box (drop-down list box: A control on a data access page that, when clicked, displays a list from which you can select a value. You cannot type a value in a drop-down list box.) if you are working in a data access page.

List boxes The list in a list box consists of rows of data. In a form, a list box can have one or more columns, which can appear with or without headings. If a multiple-column list box is bound (bound control: A control used on a form, report, or data access page to display or modify data from a table, query, or SQL statement. The control's ControlSource property stores the field name to which the control is bound.), Access stores the values from one of the columns. In a data access page, a list box has one column without a heading.

List box value stored in underlying field

Callout 1 When you click a value in a list box...

Callout 2...if the list box is bound, Access inserts the value selected into the field that the list box is bound to. If the bound column (bound column: The column in a list box, combo box, or drop-down list box that's bound to the field specified by the control's ControlSource property.) is different from the column displayed in the list, Access inserts the value from the bound column instead of the value you clicked.

Callout 3 This is the underlying record source that the form is bound to.

You can use an unbound (unbound control: A control that is not connected to a field in an underlying table, query, or SQL statement. An unbound control is often used to display informational text or decorative pictures.) list box to store a value that you can use with another control (control: A graphical user interface object, such as a text box, check box, scroll bar, or command button, that lets users control the program. You use controls to display data or choices, perform an action, or make the user interface easier to read.). For example, you could use an unbound list box to limit the values in another list box or in a custom dialog box (custom dialog box: A modal pop-up form you create to ask the user for additional information or to display a message.). You could also use an unbound list box to find a record based on the value you select in the list box.

Combo boxes     A combo box is like a text box and a list box combined, so it requires less room. You can type new values in it, as well as select values from a list. The list in a combo box consists of rows of data. Rows can have one or more columns, which can appear with or without headings.

Combo box combines text box and list box functionality

Callout 1 Type text directly into a combo box...

Callout 2...or click the arrow...

Callout 3...to see a list of values to choose from.

When you enter text or select a value in a bound (bound control: A control used on a form, report, or data access page to display or modify data from a table, query, or SQL statement. The control's ControlSource property stores the field name to which the control is bound.) combo box, the entered or selected value is inserted into the field that the combo box is bound to. If a multiple-column combo box is bound, Access stores only the value from the bound column. You can use an unbound (unbound control: A control that is not connected to a field in an underlying table, query, or SQL statement. An unbound control is often used to display informational text or decorative pictures.) combo box to store a value that you can use with another control (control: A graphical user interface object, such as a text box, check box, scroll bar, or command button, that lets users control the program. You use controls to display data or choices, perform an action, or make the user interface easier to read.). For example, you could use an unbound combo box to limit the values in another combo box or in a custom dialog box (custom dialog box: A modal pop-up form you create to ask the user for additional information or to display a message.). You could also use an unbound combo box to find a record based on the value you select in the combo box.

Drop-down list boxes On a data access page, you can use a drop-down list box (drop-down list box: A control on a data access page that, when clicked, displays a list from which you can select a value. You cannot type a value in a drop-down list box.) instead of a list box. A drop-down list box on a data access page looks like a combo box on a form. As in a combo box, a drop-down list box shows only one record until you click to expand the contents; however, you can't type new values in a drop-down list box. The list in a drop-down list box consists of rows of data. Rows can have only one column that appears without headings.

Select a value from a drop-down list box

Callout 1 Click the arrow...

Callout 2...to see a list of values to choose from.

When you select a value in a drop-down list box that is bound to a field, the selected value is inserted into that field. You can also use an unbound drop-down list box to store a value that you can use with another control. For example, you could use an unbound drop-down list box to limit the values in another drop-down list box. You could also use an unbound drop-down list box to find a record based on the value you select in the drop-down list box.

ShowCommand buttons

Command buttons provide you with a way of performing action(s) by simply clicking them. When you choose the button, it not only carries out the appropriate action, it also looks as if it's being pushed in and released.

ShowWhat are command buttons?

You use a command button on a form or data access page (data access page: A Web page, published from Access, that has a connection to a database. In a data access page, you can view, add to, edit, and manipulate the data stored in the database. A page can also include data from other sources, such as Excel.) to start an action or a set of actions. For example, you can create a command button that opens another form. To make a command button do something on a form, you write a macro (macro: An action or set of actions that you can use to automate tasks.) or event procedure (event procedure: A procedure that is automatically executed in response to an event initiated by the user or program code, or that is triggered by the system.) and attach it to the button's OnClick property. On a data access page, you can attach code written in either Microsoft JScript or Microsoft Visual Basic Scripting Edition (VBScript) (Visual Basic Scripting Edition (VBScript): A subset of the Microsoft Visual Basic programming system. At least Microsoft Internet Explorer 3, along with the other Web browsers, can read VBScript programs that are embedded in HTML pages.) to a command button by using the Microsoft Script Editor (Microsoft Script Editor: Used to add text, edit HTML tags, and edit any Microsoft Visual Basic Scripting Edition (VBScript) code in a data access page. You can also view your page in the Script Editor as it would appear in a Web browser.).

You can display text or a picture on a command button in a form; you can display only text on a command button in a data access page.

ShowCreating command buttons

You can create a command button on your own, or you can have Microsoft Access create your command button for you by using a wizard. A wizard speeds up the process of creating a command button because it does all the basic work for you. When you use a wizard, Access prompts you for information and then creates the command button based on your answers. By using the wizard, you can create more than 30 different types of command buttons. You can create command buttons to:

  • Dial a phone number.
  • Run a query or macro.
  • Run or quit an application.
  • Edit or apply a filter.
  • Print or mail a report.
  • Print the current record.
  • Update form data.
  • Find a specific record.

It's also a good idea to use the Command Button Wizard if you want to learn how to write event procedures. When Access creates a command button in a form or report with a wizard, it creates an event procedure and attaches it to the button. You can open the event procedure to see how it works and modify it to fit your needs. When you create a command button on a data access page with a wizard, Access doesn't create event procedures for you.

Wizards are not available in a stand-alone data access page or when you point a data access page to a database other than the one currently open. The Command Button Wizard is also not available if a data access page isn't bound to a table or query. You will have to create a command button on your own if wizards aren't available.

ShowCheck boxes

You can use a check box on a form, report, or data access page (Design view: A view that shows the design of these database objects: tables, queries, forms, reports, and macros. In Design view, you can create new database objects and modify the design of existing objects.) as a stand-alone control (control: A graphical user interface object, such as a text box, check box, scroll bar, or command button, that lets users control the program. You use controls to display data or choices, perform an action, or make the user interface easier to read.) to display a Yes/No value from an underlying table, query, or SQL statement. For example, the check box in the following illustration is bound (bound control: A control used on a form, report, or data access page to display or modify data from a table, query, or SQL statement. The control's ControlSource property stores the field name to which the control is bound.) to the Discontinued field in the Products table. The data type of the Discontinued field is Yes/No. If the box contains a check mark, the value is Yes; if it doesn't, the value is No.

Check box bound to a field with a Yes/No data type

Callout 1 This stand-alone check box is bound to the Discontinued field in the Products table.

When you select or clear a check box that's bound to a Yes/No field in a Microsoft Access database (Microsoft Access database: A collection of data and objects (such as tables, queries, or forms) that is related to a particular topic or purpose.) or a Bit column in an Access project (Microsoft Access project: An Access file that connects to a Microsoft SQL Server database and is used to create client/server applications. A project file doesn't contain any data or data-definition-based objects, such as tables and views.), Access displays the value in the underlying table according to the field's Format property (Yes/No, True/False, or On/Off). In an Access project, the option button is bound to a column defined as a Bit data type. When the value in this column is 1, it is equivalent to Yes, On, or True conditions. When the value is 0, the column indicates No, Off, or False conditions.

You can use check boxes in an option group (option group: A frame that can contain check boxes, toggle buttons, and option buttons on a form or report. You use an option group to present alternatives from which the user can select a single option.) to display values to choose from.

ShowOption buttons

You can use an option button on a form, report, or data access page (data access page: A Web page, published from Access, that has a connection to a database. In a data access page, you can view, add to, edit, and manipulate the data stored in the database. A page can also include data from other sources, such as Excel.) as a stand-alone control (control: A graphical user interface object, such as a text box, check box, scroll bar, or command button, that lets users control the program. You use controls to display data or choices, perform an action, or make the user interface easier to read.) to display a Yes/No value from an underlying record source (record source: The underlying source of data for a form, report, or data access page. In an Access database, it could be a table, query, or SQL statement. In an Access project, it could be a table, view, SQL statement, or stored procedure.). For example, the option button in the following illustration is bound (bound control: A control used on a form, report, or data access page to display or modify data from a table, query, or SQL statement. The control's ControlSource property stores the field name to which the control is bound.) to the Discontinued field in the Products table of a database. The data type of the Discontinued field is Yes/No. If the option button is selected, the value is Yes; if not, the value is No.

Stand-alone option button displaying Yes value bound to field

Callout 1 This stand-alone option button is bound to the Discontinued field in the Products table. The value in the field is Yes.

When you select or clear an option button that's bound to a Yes/No field in a Microsoft Access database (database: A collection of data related to a particular subject or purpose. Within a database, information about a particular entity, such as an employee or order, is categorized into tables, records, and fields.), the value in the underlying table displays according to the field's Format property (Yes/No, True/False, or On/Off). In a Microsoft Access project (Microsoft Access project: An Access file that connects to a Microsoft SQL Server database and is used to create client/server applications. A project file doesn't contain any data or data-definition-based objects, such as tables and views.), the option button is bound to a column defined as a Bit data type. When the value in this column is 1, it is equivalent to Yes, On, or True conditions. When the value is 0, the column indicates No, Off, or False conditions. You can also use option buttons in an option group (option group: A frame that can contain check boxes, toggle buttons, and option buttons on a form or report. You use an option group to present alternatives from which the user can select a single option.) to display values to choose from.

ShowOption groups

You can use an option group on a form, report, or data access page (data access page: A Web page, published from Access, that has a connection to a database. In a data access page, you can view, add to, edit, and manipulate the data stored in the database. A page can also include data from other sources, such as Excel.) to display a limited set of alternatives. An option group makes selecting a value easy because you can just click the value that you want. Only one option in an option group can be selected at a time. If you want to present more than a few options, use a list box (list box: A control that provides a list of choices. A list box consists of a list and an optional label.), a combo box (combo box: A control used on a form that provides the combined functionality of a list box and a text box. You can type a value in a combo box, or you can click the control to display a list and then select an item from that list.), or a drop-down list box (drop-down list box: A control on a data access page that, when clicked, displays a list from which you can select a value. You cannot type a value in a drop-down list box.) instead of an option group.

In a form or report, an option group consists of a group frame as well as a set of check boxes, option buttons, or toggle buttons. In a data access page, an option group consists of a group frame and a set of option buttons.

Option group

Callout 1 Label

Callout 2 The option group is the frame that surrounds the controls inside it.

Callout 3 Option buttons

Callout 4 Only one option in an option group can be selected at a time.

If an option group is bound to a field, only the group frame itself is bound — not the check boxes, toggle buttons, or option buttons inside the frame. Because the ControlSource property of the group frame is set to the field that the option group is bound to, you don't set the ControlSource property for each control (control: A graphical user interface object, such as a text box, check box, scroll bar, or command button, that lets users control the program. You use controls to display data or choices, perform an action, or make the user interface easier to read.) in the option group. Instead, you set the OptionValue (form or report) or the Value (data access page) property of each check box, toggle button, or option button. In a form or report, set the control property to a number that's meaningful for the field the group frame is bound to. In a data access page, set the control property to either a number or any text that's meaningful for the field the group frame is bound to. When you select an option in an option group, Access sets the value of the field to which the option group is bound to the value of the selected option's OptionValue or Value property.

Selected option in an option group

Callout 1 OptionValue property set to 1; when you click this button, Access sets the value of the Ship Via option group to 1 and stores this number in the underlying table.

Callout 2 OptionValue property set to 2

Callout 3 OptionValue property set to 3

 Notes 

ShowToggle buttons

You can use a toggle button on a form as a stand-alone control (control: A graphical user interface object, such as a text box, check box, scroll bar, or command button, that lets users control the program. You use controls to display data or choices, perform an action, or make the user interface easier to read.) to display a Yes/No value from an underlying record source (record source: The underlying source of data for a form, report, or data access page. In an Access database, it could be a table, query, or SQL statement. In an Access project, it could be a table, view, SQL statement, or stored procedure.). For example, the toggle button in the following illustration is bound (bound control: A control used on a form, report, or data access page to display or modify data from a table, query, or SQL statement. The control's ControlSource property stores the field name to which the control is bound.) to the Discontinued field in the Products table of a database. The data type of the Discontinued field is Yes/No. When the button is pressed in, the value in the Products table is Yes. When the button isn't pressed in, the value in the Products table is No.

Toggle button indicates Yes/No, True/False, or On/Off conditions

Callout 1 This stand-alone toggle button is bound to the Discontinued field in the Products table. The button is pressed in, so the value in the field is Yes.

When you click a toggle button that's bound to a Yes/No field in a Microsoft Access database (database: A collection of data related to a particular subject or purpose. Within a database, information about a particular entity, such as an employee or order, is categorized into tables, records, and fields.), the value in the underlying table displays according to the field's Format property (Yes/No, True/False, or On/Off). In an Access project (Microsoft Access project: An Access file that connects to a Microsoft SQL Server database and is used to create client/server applications. A project file doesn't contain any data or data-definition-based objects, such as tables and views.), the option button is bound to a column defined as a Bit data type. When the value in this column is 1, it is equivalent to Yes, On or True conditions. When the value is 0, the column indicates No, Off, or False conditions.

Toggle buttons are most useful when used in an option group (option group: A frame that can contain check boxes, toggle buttons, and option buttons on a form or report. You use an option group to present alternatives from which the user can select a single option.) with other buttons. In an option group, you can easily tell whether a button is pressed in.

Also, you can use pictures on toggle buttons instead of text. For example, instead of displaying the word "Discontinued" on the toggle button in the first example, you could display a picture of a trash can.

ShowTabbed pages on forms

You can use a tab control to present several pages of information as a single set. This is especially useful when you're working with many controls that can be sorted into two or more categories. For example, you might use a tab control on an Employees form to separate employment history and personal information.

Tab control with two tabs

Callout 1 Information about employment history is displayed on this page.

Callout 2 Personal information, such as home address and phone number, is displayed on this page.

Additional controls that you can use on data access pages

ShowBound span control

You can store HTML code in a field in a table, and when the data access page (data access page: A Web page, published from Access, that has a connection to a database. In a data access page, you can view, add to, edit, and manipulate the data stored in the database. A page can also include data from other sources, such as Excel.) displays the values in that field, the HTML code performs the actions that you specified. You can accomplish this by binding the bound span control (bound span control: A control that is used on a data access page to bind HTML code to a Text or Memo field in an Access database or to a text, ntext, or varchar column in an Access project. You cannot edit the contents of a bound span control.) to a Text or Memo field in a Microsoft Access database (Microsoft Access database: A collection of data and objects (such as tables, queries, or forms) that is related to a particular topic or purpose.) or a text, ntext, varchar, or any other column that can store text in a Microsoft Access project (Microsoft Access project: An Access file that connects to a Microsoft SQL Server database and is used to create client/server applications. A project file doesn't contain any data or data-definition-based objects, such as tables and views.). The contents of a bound span control are not editable.

For example, if a value in a field is <font color=red>red Text</font> and you set the DataFormatAs property to HTML, you will see red text when you view the data access page in Page view (Page view: An Access window in which you can browse the contents of a data access page. Pages have the same functionality in Page view as in Microsoft Internet Explorer 5.0 or later.). If the DataFormatAs property is set to Text, then <font color=red>red Text</font> is the value displayed in the control. The default value of the DataFormatAs property is Text.

If the HTML text is lengthy, bind the bound span control to a field with the Memo data type (Access database), or the text or ntext data type (Access project).

 Notes 

  • You can make the bound span control the default control for a grouped data access page. Set the DefaultControlType property of the data access page to Bound Span.
  • You can use a bound span control to display calculations and data on a grouped data access page. In Microsoft Internet Explorer 5.01 with Service Pack 2 (SP2) or later, bound span controls load faster than other controls, and hence improve the performance of the page.
  • The bound HTML control in Access 2000 has been replaced by the bound span control in Access 2002 and later. Bound HTML controls on pages created using Access 2000 will automatically convert to bound span controls when you open the page in Access 2002 or later.

Security  Use bound span controls or hyperlink controls with caution. Unauthorized users may be able to insert harmful HTML text into these controls. Processing this text without validation or modification could result in the loss of personal information or other data. To prevent the HTML text contained in a control from being rendered, encode the contents of the control.

ShowHyperlink control

Use the hyperlink control when each record in the underlying record source (record source: The underlying source of data for a form, report, or data access page. In an Access database, it could be a table, query, or SQL statement. In an Access project, it could be a table, view, SQL statement, or stored procedure.) has a different hyperlink address. You bind the hyperlink control to a Text field that contains hyperlink values, such as e-mail addresses.

As you move from record to record in Page view (Page view: An Access window in which you can browse the contents of a data access page. Pages have the same functionality in Page view as in Microsoft Internet Explorer 5.0 or later.) or Microsoft Internet Explorer, you can click the hyperlink to either go to a different Web page or open a mail program to send an e-mail message.

Security  Use bound span controls or hyperlink controls with caution. Unauthorized users may be able to insert harmful HTML text into these controls. Processing this text without validation or modification could result in the loss of personal information or other data. To prevent the HTML text contained in a control from being rendered, encode the contents of the control.

ShowImage hyperlink control

Use the image hyperlink control to add an image to a data access page that, when clicked, displays another Web page from your hard drive, the Web, or another location. When you create an image hyperlink control, you select the image to display on the page and the address of the file to jump to. In Page view (Page view: An Access window in which you can browse the contents of a data access page. Pages have the same functionality in Page view as in Microsoft Internet Explorer 5.0 or later.), as the pointer passes over the image, the pointer changes to a hand, indicating that the image is a link that you can click to go to another page. You can also define ScreenTips (ScreenTip: A short description that appears when the user holds the mouse pointer over an object, such as a button or hyperlink.) and alternate text for the image.

The image hyperlink control is useful for providing links to information that relates to data on your data access page.

ShowScrolling text control

 
 
Applies to:
Access 2003