Share this Page URL

Chapter 1. The HelloWorld Database > Building a Data Entry Form - Pg. 9

The HelloWorld Database 9 Saving a table without a primary key You can save a table without designating a primary key field, but doing so limits what you can do with the table. Without a primary key, you have no guarantee that each record in the table is unique, and you can't easily relate records in that table to records in another. If you attempt to save a table before you designate a primary key, Access displays a warning and indicates that it can create a primary key field for you. If you say Yes, Access adds an AutoNumber field to the table, naming the field ID. 3. 4. On the File menu, click Save. In the Save As dialog box, enter Greetings as the table name. Close the Table Design window. Just the Steps Create a simple table 1. 2. 3. 4. 5. In the Database window, select Tables in the Objects list, and then click New on the Database window toolbar. Enter field names, select data types for the fields, and enter a description for the field. Set field properties such as Field Size. Designate a primary key field for the table (or let Access add an AutoNumber field named ID to the table). Save and name the table. Building a Data Entry Form Now that we have a table set up, we'll create a form that we can use to enter data in the table. Access will do most of the initial work with its Form Wizard. Forms are one of the main features of most every database you create in Access. You can enter data into a table without a form, using what Access calls the Datasheet view of the table, but using a form has many advantages. For one thing, you can design forms that resemble the user interfaces you're familiar with in Access and other applications. These forms use text boxes, drop-down lists, and buttons--items known as controls--to make entering data and accomplishing tasks almost effortless. Forms are also a means by which you can view and enter related data because you can include fields from more than one table. Of course at this point, the form we'll create will be based only on the Greetings table. The Form Wizard provides a set of standard options for the look and feel of a form, which means that you don't have to spend time aligning a list box precisely with its label, choosing a font and font size for labels, or selecting a background design. You can do all this work yourself--and you'll learn how in later chapters--but for now, we'll make use of the standard formats the wizard provides. Here are the steps to create the data entry form. Create a data entry form 1. 2. In the Database window, select the Greetings table. On the Insert menu, click Form. You'll see the New Form dialog box, shown here. Notice that in this dialog box, the Greetings table is selected as the table from which the form's data will come. The Greetings table is known as the form's record source.