Database Basics
• Create a new database • Create tables • Create records • Create forms • Create queries • Create reports • Hands‐On PracticeCreate a new database
Open Microsoft Access. It should look like this: In the Getting Started pane, click Create a new file. When the New File pane appears, click Blank Database.When the File New Database window appears, create a new folder in the My Documents folder called Practice Access Files. TIP: To create a new folder, double‐click the My Documents folder so it appears in the Save in drop‐down list. Then click the icon. Double‐click the Practice Access Files folder. It should appear in the Save in box. In the File name box, type: Friends.mdb TIP: The file extension for Access databases is .mdb. Just like Word files are something.doc, and Web pages are somethingelse.html, Access databases are database.mdb. MDB stands for “Microsoft DataBase.” Click the button. The window for the Friends database should open:
Identify database elements Elements of databases A database stores information in an organized way, and makes it easy to get information in and out. Tables store data within the database. Forms make it easy to put data into tables. Queries pull out specific data. Reports put data in an easily‐read format.
In the Objects list, click Tables. Click Queries. Click Forms. Click Reports.
Click Tables.
Click the button. The Friends database window should expand to fill the screen.
Create tables
Double‐click Create table by entering data.
A blank table should open:
Name fields Double‐click the Field 1 column header. Type: First Name Press the ENTER key on your keyboard. The column header should look like this: Double‐click the Field2 column header. Type: Last Name It should look like this: Press the ENTER key on your keyboard.
Double‐click the Field4 column header, type: Zip then press ENTER. Double‐click the Field5 column header, type: Phone Number then press ENTER. The table should now look like this:
Delete unused fields
Right‐click the Field6 column header. When the menu appears, click Delete Column.When the alert window appears, click the button. Right‐click the Field7 column header. When the menu appears, click Delete Column. When the alert window appears, click the button. Delete the Field8, Field9, and Field10 columns the same way. The table should now look like this:
On the Menu Bar, click File, then Save.
When the Save As window appears, type: Friends of Mine in the Table Name box. Click the button.
When the alert window that reads There is no primary key defined appears, click the button. Access will insert an ID field—the Key field—in the table:
What is the key field?
When the alert window popped up, and you clicked the button, Access added the ID field to the table. The ID field is now the table's primary key, or key field. That means it can't contain any duplicates. Every table should have a key field. For example, if a hospital keeps a database, each patient can have a unique ID number in the key field. That way, if it has more than one patient named John Baker, it can easily distinguish John Baker, ID #326 in for a checkup, from John Baker, ID #298 who needs his gall bladder removed.Create records
Click in the box under the First Name column header. Type: Elvis Press the TAB key on your keyboard. The table should now look like this: Type: Presley then press the TAB key. Type: Baltimore then press TAB. Type: 21212 then press TAB. Type: 4105551212 then press TAB. The table should now look like this: TIP: Notice how the cursor in the row selector has moved down to the second (new) record. When you move on to a new record, Access automatically saves the previous record.Add new fields
Right‐click the Zip column heading.When the menu appears, click Insert Column. The table should now look like this, with a new blank field: Double‐click the column heading and type: State Press the ENTER key. Click inside the new State field for the first record. Type: MD Press TAB until the cursor moves down to a new record. Record number 1 is saved and complete.
Move fields
Click the Phone Number column heading. The entire column should be selected. Place the cursor on the Phone Number column heading. Then drag the column so the cursor rests between the Last Name and City columns. When you see a thick black line between the two columns, release the mouse button. The Phone Number column should now rest between the Last Name and City columns: On the Menu Bar, click File, then Close. When prompted to save the changes to the table layout, click the button.The Friends database window should now look like this:
Create forms
In the Objects list, click Forms.
Double‐click Create form by using wizard.
When the Form Wizard window appears, click the button.
All the table fields should be added to the form:
When the next screen appears, leave Columnar selected, then click the button.
When the next screen appears, make sure Standard is selected, then click the button.
When the last screen appears, type: Friends of Mine Data Input Form in the box.
Click the button.
Add a new record
In the form window, click the button located at the bottom of the form. A blank record should appear. Press TAB to advance to the First Name box. Type: Bo then press the TAB key. Type: Diddley then press the TAB key. Type: Richmond then press the TAB key. Type: VA then press the TAB key. Type: 23220 then press the TAB key. Type: 8005557890 The form should now look like this: Press the TAB key again.The form should progress to a new, blank record: The old record has been saved.
On the Menu Bar, click File, then Close to return to the database window.
Create queries
What's a query?
A query is a way to get specific information from the database. Essentially, it's a question. You use queries to ask the database things like, "Who are my customers in Montana?", or "How many pipe fittings have I sold this month?"In the Objects list, click Queries. Double‐click Create query by using wizard. When the Simple Query Wizard opens, double‐click First Name in the Available Fields list. First Name should appear in the Selected Fields column:
Click the button.
This should add the Last Name field to the Selected Fields list:
Double‐click Phone Number.
Click the button.
When the final screen appears, type: Names and Numbers Click the button. The query is automatically saved and executed. It should look like this: On the Menu Bar, click File, then Close to return to the database window.
Create reports
In the Objects list, click Reports. Double‐click Create report by using wizard. When the Report Wizard window appears, click the Tables/Queries drop‐down arrow. When the list appears, click Table: Friends of Mine. Click the button to move all the fields into the Selected Fields list.In the Selected Fields list box, click ID, then click the button. The ID field should be removed. The report wizard should now look like this: Click the button.
When the next screen appears, click the button.
When the next screen appears, click the first drop‐down arrow, then click State in the list. Click the button.
Choose layout and style
When the next screen appears, make sure Tabular is checked in the Layout section.When the next screen appears, click Soft Gray in the list of available styles. Then click the button.
View the report
When the final screen appears, type: My Friends in the box. Then click the Preview the report radio button.Click the button. The report is automatically created, saved and opened. It should look like this: On the Menu Bar, click File, and then Close to return to the Friends database window.
On the Menu Bar, click File, then Exit to close Access.
Practice: Database Basics
1. Open Microsoft Access. 2. Create a blank Access database in the Practice Access Files folder called Music Library.mdb. 3. Create a new table with these fields: CD Title Artist Genre Date Purchased Number of Songs5. Save the table as CDs. Allow Access to create a Primary Key. 6. Rename the ID field (the Primary Key) Album ID. 7. Enter these data into the table to create the first record: CD Title: Pearls on a String Artist: Dusty Trails Genre: Folk Date purchased: 05/10/2001 Number of Songs: 14 It should look like this: 8. Close the CDs table. 9. Create a form for inputting data into the CDs table. 10. Save it as CDs Table Data Input. It should look like this: 11. Use the form to enter information for four more CDs. TIP: Feel free to make things up. 12. Create a query that pulls out this information: CD Title Genre Number of Songs
13. Save the query as Quick CD Notes. Run the query. It should look like this: Create a report based on the CDs table. 14. Include all the fields of the CDs table in the report, and sort the records based on Genre. TIP: Format the report using the Soft Gray style. 15. Name the report CD Inventory. It should look like this: 16. Close the report. 17. Exit Microsoft Access.