




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A lab guide for using microsoft access to maintain and extend a movie database. It covers the basics of adding, editing, and removing data using forms, and discusses the advantages of using forms over tables. Students will learn how to add a new movie and director to the database, confirm data entry, delete a table row, and create a form to simplify editing data.
Typology: Lab Reports
1 / 8
This page cannot be seen from the preview
Don't miss anything!





This is the first of two labs that covers the basic skills you will need to maintain, extend, and create databases. In the previous lab, we focused on viewing the data in the database using tables and queries. These are essential skills in working with a database, but most databases, including our movie database, become less useful with time without some maintenance. The common database maintenance tasks we will focus on in this lab are adding, removing, and editing entity data, i.e., rows of tables. Although you can do all of these by working directly with tables, we’ll see how forms can often be a more convenient way.
Write your answers after completing the lab, but read them carefully now and keep them in mind during the lab.
We’ll continue using the same database as in the previous lab: movies.mdb, which contains data on movies and directors. Start with the database file you ended up with at the end of the previous lab.
Part 1. Adding and Removing Rows
Suppose we want to add a new movie and director to our movie database. Start thinking of a movie you might want to add (maybe using the web to look up the director), but for this exercise, make sure the director is not already in the database, so we can practice adding data to both the Movie and Director tables. If you can’t think of a movie, you can just add Mo’ Better Blues by director Spike Lee. Before you do, however, you might want to refresh your memory on how this database stores representations of entities (movies and directors, in this case): the Movie and Director tables’ fields and their data types.
Based on the fields in each of the tables, which should be added first: movie or director? Explain your answer.
You can always add rows to a table (or edit existing rows) by opening a table in Datasheet View. This view shows all of the rows currently in the database, and the very last row (marked by an asterisk on the far left) is for adding new data. Adding a new row is as simple as entering field values in that last row.
The controls at the bottom of the table subwindow can also be used to quickly begin adding a new row. The rightmost button, labeled with a triangle and an asterisk, brings you to the new row at the bottom of the table.
Add rows for the new movie and director. FYI, Mo’ Better Blues was released in 1990, and Spike Lee was born in 1957.
How could you use a query to confirm that you entered the correct value of DirectorID in the new Movie row?
If, for some reason, you need to delete a table row, you can also do this using the Datasheet View. One easy way to delete a table row is by clicking anywhere in the row
you want to delete and clicking the toolbar button for Delete Row.
What happens when you try to do this?
Is it strictly necessary to delete the rows for Majid Majidi’s movies in the Movie table in order to delete his row in the Director table?
in Datasheet View, you had to remember the director’s DirectorID. Next, you’ll see how we can create forms in Access to simplify editing data.
Specifically, you’ll create a form like the one shown below, which allows you to choose a movie’s director from a combo box. (A “combo box” is an interface where you can either type in text or select from a list that drops down when the down-arrow button is clicked.) We will set up the combo box so that when a user selects a director from the drop-down list, the current movie’s DirectorID field will be set to the selected director’s DirectorID. No more DirectorIDs to remember! (Note that this form also hides the movie’s ID number, since you don’t normally need to know this field value, either.)
As with many other tasks in Access, rather than creating a form from scratch, you can use a wizard to produce one based on an existing table or query. In this case, the form will be based on the Movie table. The wizard lets you choose which fields you want in the form and how you want the form to look.
At this point you’ve selected the content for your form, i.e., what fields you want in it. In the next two steps, you’ll choose how you want your form to look.
”. You can experiment with other options later.
At this point, you should be in Form View with the Movie form showing the title and year of release for one row of the Movie table. At the bottom of the form’s subwindow, there are some controls for navigating rows, identical to the ones you saw for tables. Your form’s visual appearance may differ depending on your choice of visual style.
TROUBLESHOOTING: If you decide you don’t like the way your form looks and want to start over, you can close it and delete it from the Database subwindow by right-clicking the form and selecting Delete.
…but there’s something missing, of course: some way to set the DirectorID field for each movie. In the next steps, you’ll add a combo box to the form for this purpose. The combo box will display all of the directors in the Director table by name, and when a director is selected, the combo box will take care of setting the DirectorID field to the selected director’s ID number.
The last wizard step asks for a label, which is just the text that appears next to the combo box to tell the user what it’s for, so just enter “Director”.
How do you move a control? How do you move a control’s label?
How do you resize a control? ( HINT : the “handles,” the little black squares that appear on the selected control)
How do you change a control label’s text?
TROUBLESHOOTING: If you make a mistake while editing your form, Access allows you to undo your last change. If you make a lot of changes and want to undo them, you will have to close the form without saving changes and reopen it to start with the version you last saved.
Part 3. Forms to Simplify Viewing Data
In the previous part of the lab, you created a form for editing data in the Movie table. In this part, we outline the process of creating a form that allows the user to view (but not edit) the Movie table. The only major difference between a form designed for editing data and one designed for viewing data is that the controls on the viewing form are locked. That is, they don’t permit the user to change the values they display. (We can also say these controls are “ready only,” in the sense that we can only read, but not change, their contents.)
The first steps of creating a form for viewing data are the same as for any other form. It’s recommended that you use the form wizard to get started. Once you have the controls you want on the form, you can lock them as described below.
Close the property window and switch to Form View, saving the changes to the form. You should be unable to make changes to the contents of the control you just locked. (You will be able to click and select the contents, but nothing should happen when you type inside.)
We will leave creating a form for viewing data as an optional activity.