You are on page 1of 23

Chapter 1: Getting Started with Access Access provides a powerful yet comfortable environment in which you can manage

your information. Using Access, you can tame even the most difficult data-management tasks. This chapter is the first step in your journey. Here you will learn basic terms, as well as how to start and exit Access. You will also learn how to get help and even catch a glimpse of what you can do with Access. By the time you finish this chapter, you will understand the following key concepts:

What a database is How tables, forms, and queries relate to a database What records and fields are How to start Access The parts of the Access environment How Wizards can help you How to get help when using Access Possible uses for both databases and Access How to exit Access

Access Terminology Before you dive into the Access environment, there are a few terms with which you should be familiar. As such, we'll discuss these terms now and make sure you understand them. The following sections discuss the major terms which you must understand before you work with Access. What is a Database? A database is simply a collection of related information. For example, if you gathered together all your photographs, you would have a database of photographs. If you collected all your photographs that included your

dog, you would have either a more targeted database or a subset of your larger database. If your database is small (for example, your home insurance policies), you can probably manage the information manually. In such instances, you might use a traditional management method such as a card file or a simple list on a piece of paper. However, as the database becomes larger, your management task becomes more difficult. For example, it would be virtually impossible to manually manage the customer database of a large corporation. This is where your computer and a database management system (DBMS) come in handy. DBMS software (such as Access) lets you manage large amounts of information quickly and easily. In Access, a database consists not just of information, but also the tables into which the information is organized. Access databases also contain related queries, forms, reports, and programming instructions. Because these terms deserve further definition, they are covered in the following sections. What is a Table? In Access, tables contain the actual information in your database. There can be more than one table in a database. The information in each table can relate to information in other tables in your database. For example, you might have one table that contains a record of all the door locks in your building. In the same database, another table might have a list of all the keys for those locks. Still another table might contain the names of all the people who have the keys. All three tables contain related information, so they belong to the same database. Figure 1-1 depicts the relationship between the tables and this database.

Figure 1-1 How Access relates tables and databases. Your first step in creating a database is to determine the information you need. Next, you will use Access to design a table to hold the information. Figure 1-2 illustrates the Design view of Access. You use Design view to specify the framework used for each of your table entries.

Figure 1-2 Design view for a table in Access. After you design your table or tables, you will use Datasheet view to enter and examine (view) your data. Figure 1-3 illustrates how your data may appear in Datasheet view mode.

Figure 1-3 Datasheet view for a table in Access. What is a Query? When you work with large databases, there will be times when you will want to work with specific pieces of your data. For example, if you have a company database, you may want to view the names of all your customers who reside in New York. On such occasions, you would form a query. A query defines which database information you want to view. Think of a query as a question you ask the database, such as "Who are the customers that reside in New York?"

For example, if your database contains the names of all your customers who have purchased a particular product, your query might request a list of only those customers that made over a certain income. Another query might request only those customers with children. Essentially, a query limits or filters the information in a database. When you use a query as a filter, Access displays only information that satisfies the query. Why would you use queries? Specifically because you want to work with only a part of your database. Queries make it easy for you to work with only those records that fit a particular criterion. Access lets you get as broad or as specific or as complex as you want in the queries you develop. What is a Form? A database exists to store information. After you determine the information your database will contain, you will need to enter the data. Later, you may want to examine, add to, or change that data. Although you can use the Datasheet view to accomplish each of these tasks, you may want instead to create a custom display screen that lets you enter, view, and edit information. Within Access, custom display screens are called forms. Using forms, you can both display the information in a table and add buttons, text boxes, labels, and other objects that make data entry much easier. Earlier, in Figure 1-3, you saw what a table looked like as a Datasheet. Figure 1-4 shows an example of a form used to input information into the same table. Notice how using the form provides a better interface for the user.

Figure 1-4 An example of a form used to enter information in a table. What is a Record? A record is a single block of information, such as employee or customer data. A table is made up of many records. For example, if you have a table that contains information about your baseball card collection, a record is the specific information about a single baseball card. Sometimes, records are referred to as rows because, within a table, Access represents individual records as rows. What is a Field? Just as tables are made up of records, records are made up of fields. A field is the smallest piece of information in a database. For example, if you have a table containing your phone list, each record represents a different person or business in that list. In turn, those records are made up of individual fields (names, addresses, or phone numbers). Figure 1-5 shows the relationship of fields, records, tables, and databases.

Figure 1-5 How fields, records, tables, and databases are related. You may also hear fields referred to as columns. Within tables, Access represents fields as columns when you look at data in Datasheet view (refer back to Figure 1-3).

Creating Your Own Database To create your own database, you can use any of three methods:

Click your mouse on the New tool (it is the leftmost tool on the toolbar; it looks like a blank sheet of paper). Choose New Database from the File menu. Press CTRL+N.

Regardless of which method you choose, you will see the New dialog box shown in Figure 2-1.

Figure 2-1 The New dialog box. The New dialog box allows you to specify how you want to create your new database. There are many choices on the General tab (Figure 2-1) and the other two tabs in the dialog box. The choices provide different ways to accomplish the same ends. The selection you make in the New dialog box serves as the starting point, or template, for a new Access database.

Figure 2-2 The File New Database dialog box. . To use the File New Database dialog box, just specify the name you want to use for your database and where you want to store the database on disk. Choosing a Database Name You can name your database anything you want, but the filename must follow the same conventions you would use for any disk filename. Do not include a filename extension (the part of the filename to the right of the period); Access will provide the file extension based on its rules. Where Should You Store Your Database? After you specify your database name and location, click your mouse on the Create button. Access creates the new database, using the name you provided, and displays the Database window shown in Figure 2-3. Notice that the name of your database is shown at the top of the Database window.

10

Figure 2-3 The Database window for your new database.

11

Adding and Editing Fields In most ways, the Design view window operates like the Datasheet window. Access lets you add fields, move fields, or change field names without affecting the information contained in your current fields. To add a field, select the first blank row in the layout (this is the last row) or insert a row. To insert a row, select the field before which you want to insert the new field. Then choose the Insert Row option from the Edit menu or click your mouse on the Insert Row tool. When you insert a new field, Access moves all the subsequent fields down and inserts an empty field in the layout. For instance, assume that you want to add a field for the middle initial of your friends. Naturally, you would place this field between the first name and last name fields. To add the field, perform the following steps: 1. Select the third row of the layout and make it the current row. (This is the row that defines the LastName field.) 2. Click your mouse on the Insert Row tool. This adds a blank row between FirstName and LastName, as shown in Figure 3-2.

12

Figure 3-2 Inserting a blank row in your table layout. Now you can enter the new field name. In this case, type Middle Initial (you can include the space). That's all there is to adding a field. In the next section, you will learn how you can specify the type of information (text, numbers, and so on) that the new field will contain.

As you work with table fields, there may be times when you want to move a field. To move a field, select the field's row (make sure the entire row is highlighted) and then move the mouse point to the current record indicator at the left side of the record. (The current record indicator is the small triangle to the left of the record.) When you hold down the left mouse button, you can drag the field to any new position you desire. When you release the mouse button, Access moves the field to the new location. Moving a field does not harm or modify its data, nor does it change the data within any surrounding fields.

13

Your field names should describe the data that your fields contain. Over time, the information you store in a table may change. To change the name of an existing field, simply select the name and edit it. For instance, if you want to change the name of the PostalCode field to Zip Code, select the existing field name and type in Zip Code. Likewise, you may want to change the name of the StateOrProvince field to simply State. The resulting changes to your table structure (after adding the Middle Initial field and changing the StateOrProvince and PostalCode field names) are shown in Figure 3-3.

Figure 3-3 The modified table structure. Over time, you may no longer need to track specific data. As such, Access also lets you delete fields. You delete a field in much the same way you would delete records in a table: 1. Using your mouse, select the entire row containing the field you want to delete.

14

2. Press the DEL key or choose the Delete option from the Edit menu. If you are deleting a field that contains data, Access will ask you to confirm the deletion, as shown in Figure 3-4.

Figure 3-4 Access asks you to confirm the deletion. To delete the field, along with all the information previously contained in it, click your mouse on the Yes button. Changing the Information Type In order to store a piece of information efficiently, Access needs to know its data type. The data type specifies the type of information the field will contain. Access lets you specify nine different data types, as detailed in Table 3-1. Data Type AutoNum ber Currency Date/Tim e Hyperlink Memo Number OLE Object Text Yes/No Meaning A sequential number Access fills in automatically as you add records. A number accurate to 15 decimal places to the left of the decimal point and 4 places to the right. A number representing any date or time between the year 100 and 9999. An active link to another document, URL, or location within a document. A long text string, up to 64,000 characters. A numeric value. Objects such as sound clips or graphical images. (OLE is a technical term for Object Linking and Embedding, which you learn more about in Chapter 17, "Using OLE.") Any characters, up to a length of 255 characters. A yes or no value. Table 3-1 Data types supported by Access.

15

If you have been working with computers long, you may already be familiar with some of the data types listed in Table 3-1. These basic data types cover virtually every category of information you could electronically store. In the Data Type column of the Design view window, Access displays the current data type of each of your fields. If you want to change data types, select the data type entry for the field you want to change. For instance, assume you added a field called Christmas Card to your layout. The purpose of the field is to indicate whether this person is on your Christmas card list. This field is a great candidate for a Yes/No data type, but Access automatically sets the data type to text. As such, you must explicitly change it to a different data type. To do this, select the Data Type column for the Christmas Card row. You will notice a small arrow appears to the right side of the data type. If you click your mouse on the arrow, a drop-down list of available data types appears. All you need to do is select one of the data types. In this case, select Yes/No. When you leave Design view, Access converts any values in the field. Note: Changing data types can be a time consuming process, depending on how many records there are in your table. When you change a data type, Access tries to convert any existing data in the field into the new data type. If it cannot make a conversion (for instance, to or from an OLE Object), you will lose the data previously stored in the field. Adding Layout Comments When you design a table, you decide which fields the table will store, as well as each field's data type. To help you explain your decision to others who may eventually need to update the table, Access lets you place comments about each field in the table. By reading your comments, you or another user quickly knows why specific choices were made. In Design view, you can place comments about your fields in the third column of each row. The contents of the description field do not affect any Access operations; the description field is simply a place where you

16

document your thoughts or provide comments of a field's purpose. Sometime in the future, you may forget exactly why you included a particular field in your table. If you include a comment now, you are less likely to forget later. To add a comment, simply select the cell in the third column of the row that should contain the comment. You can then type anything, up to 283 characters in length. In Chapter 9, "Creating Custom Forms," you will learn how this description field can come in handy. Understanding Properties You probably noticed the area at the bottom of the Design window; this is the Field Properties area. Properties are simply characteristics associated with a field or an object. The Design window lets you change the properties associated with fields. The types of properties associated with a field depend on the field's data type. For instance, a text field has a Length property (also known as a Field Size property) which controls the number of characters the field can hold. An OLE Object (such as a sound or a picture), on the other hand, does not have such a property simply because a length would not make sense. To change a field's property, select the row that contains the field and then select or type the new property. Although many of the properties are self explanatory, some are not. The following sections explain the latter properties.

Caption A Caption is a label Access uses to refer to a field. In Datasheet view, the Caption appears above the field's column. The Caption property can be up to 255 characters. If you don't provide a Caption, Access uses the field name instead. Format The Format property describes the format Access uses for displaying a value in the field. The Format property only affects how Access displays 17

data. The Format property does not change the actual value stored in your table. You can set different formats for different data types. For example, Access provides several different formats that control how a date is displayed. Likewise, for currency fields, you can display monetary values based on several different formats. To see the available formats for a particular field, select the Format property and then click your mouse on the arrow that appears to the right of the property box. For instance, if you select the Birthdate field (which is a Date/Time data type), and then click your mouse on the Format property, an arrow will appear to the right of the property box. If you click your mouse on the arrow, you will see a drop-down list of the available formats for the field. The format name is shown to the left of the drop-down list, while an example of the format's use is shown to the right. If a pre-defined format does not meet your needs, you can create your own custom formats. You can create a custom format by putting together a series of characters that specify how the values in the field should appear. The formatting characters you use will depend on the data type of the field: Numeric or Currency, Date/Time, Yes/No, or Text or Memo. The formatting codes for Numeric or Currency data types are shown in Table 3-2. Character 0 # . , E-, E+, e-, e+ % \ -, +, $, (, ) * Meaning Provides a place holder for a digit. Access displays either a digit or a zero. Provides a place holder for a digit. Access displays either a digit or a space. Decimal point. Thousand separator. Scientific notation. Number is a percentage and is scaled by 100. Display the next character as a literal. Display as a literal character. Use the following character as the fill character (for filling empty spaces in the format).

18

Table 3-2 Custom formatting codes for Numeric or Currency data types. For example, if you wanted to develop a custom format for currency so that the numbers 1234.5678 and -1234.5678 appeared as the following: *******$1,234.57 (*******$1,234.57) you would use the following in the Format property: **$#,##0.00;(**$#,##0.00) Notice that there are actually two formats specified, separated by a semicolon. Access uses the format to the left of the semicolon if the value in the field is positive and the format to the right if the value is negative. Table 3-3 details the custom formatting codes you can use for fields with a Date/Time data type. Charac ter : / d dd ddd dddd ddddd dddddd w ww m mm mmm mmmm Meaning Time separator. Date separator. Display the day as a number without a leading zero. Display the day as a number with a leading zero. Display the day as three text characters (Sun, Mon, Tue, and so on). Spell out the full name of the day (Sunday, Monday, Tuesday, and so on). Use the short date setting from Windows Control Panel to display the full date (default is m/d/y). Use the long date setting from Windows Control Panel to display the full date (default is mmmm dd, yyyy). Display the day of the week as a number. Display the week of the year as a number. Display the month as a number without a leading zero. Display the month as a number with a leading zero. Display the month as three text characters (Jan, Feb, Mar, and so on). Spell out the full name of the month (January, February,

19

March, and so on). q Display the numeric quarter of the year. y Display the year as a number. yy Display the year as two digits. yyyy Display the year as four digits. h Display the hour as a number without a leading zero. hh Display the hour as a number with a leading zero. n Display the minute as a number without a leading zero. nn Display the minute as a number with a leading zero. s Display the second as a number without a leading zero. ss Display the second as a number with a leading zero. Display the full time using the time format specified in the tttt Windows Control Panel. Use a 12-hour clock and display the time with the suffix AM or AM/PM PM, as appropriate. Use a 12-hour clock and display the time with the suffix am or am/pm pm, as appropriate. Use a 12-hour clock and display the time with the suffix A or P, A/P as appropriate. Use a 12-hour clock and display the time with the suffix a or p, a/p as appropriate. Table 3-3 Custom formatting codes for the Date/Time data type. In most instances, the formats Access provides for the Date/Time data type will meet your needs. However, you may need to use a special format to fulfill a unique need, such as displaying the quarter of the year. For instance, suppose you wanted the dates 6/11/1999 and 1/15/2000 to appear as follows: Quarter 2, 1999 Quarter 1, 2000 In this case, you would use the following in the Format property: "Quarter "q", "yyyy Table 3-4 shows the custom formatting codes you can use when working with fields that have the Text or Memo data type. Charac ter @ Meaning Character required (either text from

20

string or a space). & Text character not required < Force all characters to lowercase > Force all characters to uppercase Table 3-4 Custom formatting codes for the Text or Memo data types. When you compare them to other formatting characters, the custom text formatting characters are fairly easy to use. As an example, assume you want to format a value so it appears all in uppercase and so that three question marks appear if the field is empty. In this case, you would use the following Format property: >;??? The code to the left of the semicolon specifies the formatting Access will apply to a text value. The code to the right directs Access to display question marks if there is no text value. The result of this Format property might appear as follows: ??? WIDGET ??? COG ??? You can also create a custom Format property for the Yes/No data type. Access internally stores this data type as one of two values: -1 for Yes and 0 for No. A custom Format property for this data type has three parts, each separated by a semicolon. Access does not use the first part, which is left blank (apparently for future versions of Access). Access uses the second part if the value is -1 and the third part if the value is 0. For example, take a look at the following Format property: ;"Left; Right" This Format property results in the text Left and Right being used instead of Yes and No. The text you use in your custom format is entirely up to you. You should note that when you are entering data for this field in the Datasheet, you still work with it as a check box; if the check box is selected, then Access translates that to Left. If it is not selected, it translates to Right.

21

Note: Remember that the Format property only affects how Access displays information; it does not modify the underlying values in the table. Input Mask Some data types let you specify an Input Mask property. An input mask guides users as they enter data. Perhaps one of the most common examples is when you enter a phone number. If you use an input mask, you might see something like this:

Notice that the parentheses are already in place for the area code and a dash appears in the proper place for the phone number itself. All the user has to do is type numbers. You specify this sort of Input Mask property as follows: !\(999") "000\-0000 You could probably tell from this example that you construct input masks in much the same way as format specifications (as covered in the previous section). In other words, you specify a series of characters that tells Access the way the mask should appear. Table 3-5 indicates the various characters you can use in the Input Mask property. Charac ter 0 9 # L ? A a & C Meaning Digit placeholder (entry required; plus and minus signs are not allowed). Digit placeholder (entry not required; empty positions converted to spaces; plus and minus signs are not allowed). Digit placeholder (entry not required; empty positions converted to spaces, plus and minus signs are allowed). Letter placeholder (entry required). Letter placeholder (entry optional). Letter or digit placeholder (entry required). Letter or digit placeholder (entry optional). Placeholder for any character or a space (entry required). Placeholder for any character or a space (entry optional).

22

. Decimal point. , Thousand separator. / or Date separator. : Time separator. < Force all following characters to lowercase. > Force all following characters to uppercase. ! Fill input mask from right to left instead of left to right. \ Display the next character as a literal. Table 3-5 Characters you can use in the Input Mask property.

23

You might also like