Lesson 5
Home Up Lesson 1 Lesson 2 Lesson 3 Lesson 4 Lesson 5 Lesson 6 Lesson 7 Lesson 8

ASCII table

Assignment 5

Forms

You can use forms for a variety of purposes.

 

 

 

 

 

 

 

 

 

Most of the information in a form comes from an underlying record source. Other information in the form is stored in the form’s design.

 

 

 

 

 

 

 

 

You create the link between a form and its record source by using graphical objects called controls. The most common type of control used to display and enter data is a text box.

 

 

 

 

 

 

 

 

 

Creating a form 

  1. In the Database window, click the Forms tab.
  2. Click New.
  3. In the New Form dialog box, click Design View.
  4. Click the name of the table or query that includes the data you want to base your form on. If the form won't contain data (for example, if you want to create a form to use as a switchboard to open other forms or reports, or if you want to create a custom dialog box), don't select anything from this list.

Note If you want to create a form that uses data from more than one table, base your form on a query that includes the tables you want to include.

5 Click OK.

Microsoft Access displays the Form window in Design view.

 

 Adding Controls to a Form

 

Create a list box or combo box that looks up values

 

To create a list box or combo box that looks up values, you need to decide two things:

· Where will the rows for the list come from?

· When a user selects an item in the list box or combo box, what will you do with that value?

The rows for a list box or combo box can come from a fixed list of values that you enter when you create the list box or combo box (use when the list won't change very often), or they can come from a table or query (use when you'll frequently update the list). For example, you could use a fixed list for a list box containing entries for Mr., Mrs., or Ms. If, on the other hand you have a Products form and you want to display a list box that lists product suppliers that will change frequently, base the list box on a table or query. The list box looks up values in the Suppliers table and displays the supplier names to choose from.

 

 

 

 

 

When a user selects a value in a list box or combo box, you have two choices. You can store the selected value in a table (not the same table that the list gets its rows from), or you can pass the value to another control. For example, for the Supplier list box, if a user selects "Pavlova, Ltd." in the preceding illustration, Microsoft Access looks up the primary key value (SupplierID) for Pavlova, Ltd. in the Suppliers table and sets the SupplierID field (the foreign key) for the current record in the Products table to the same value. This is the value that is stored. Since you're storing a value based on a selection in the list box, the list box is bound. (Note that the SupplierName value that comes from the Suppliers table is displayed in the list box but not stored.)

If, on the other hand, you want to use the value selected in the list box or combo box to determine the contents of another control or controls, you would create an unbound list box or combo box. For example, you might want to create a list box or combo box that you can use to find a related record on a form. Or you might want to create a list box or combo box that you use to filter the records in another list box or combo box.

 

Create an unbound list box or combo box that displays fixed values

 1 Open a form in Design view.

2 Make sure that the Control Wizards tool  is pressed in the toolbox.

3 Click the List Box tool  or the Combo Box tool  in the toolbox.

4 On the form, click where you want to place the list box or combo box.

Follow the instructions in the wizard dialog boxes. When the wizard asks how you want to get the values for the list, select the option that says you'll type in the values that make up the list. When the wizard asks whether you want to store the value or remember it for later use, select Choose the option Store that value in this field. Select the appropriate field.

Assignment