6.2. Working with Controls

Prior to reading this book, you probably worked with a variety of controls on Access forms, such as labels, text boxes, command buttons, and combo boxes. As you are already aware, controls can be added to a form using the Controls from the Design ribbon on the toolbar, as shown in Figure 6-6. Now turn your attention to a related topic: working with controls.

Figure 6.6. Figure 6-6

In this section, you'll explore a few ways to work with these controls through VBA code. You learned in Chapter 3 that objects have properties and methods that can be displayed in the Properties window in design view. You also learned that the properties, methods, and events of an object can be managed using VBA code. Controls are examples of objects that can be managed in these ways.

For example, you learned from the ADO examples in Chapter 5 that you can display data in a text box. An example of code that displays a value in a text box is shown here:

Me.txtLastName = rsContacts!txtLastName

Although text boxes are great for simple data entry and the displaying of a single and small value, at times you will require more sophisticated ways to display data. In the next few sections, you will look at some examples of more sophisticated controls that you can use to build more robust applications.

6.2.1. Combo Boxes versus List Boxes

Combo boxes and list boxes enable you to display ...

Get Beginning Access™ 2007 VBA now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.