access integrated project 3

Upload: mohini-sharma

Post on 02-Jun-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Access Integrated Project 3

    1/6

    Access 2013: In Practice Integrated Access Project 3 (Chapters 5-7) Page 1 of 6

    Access 2013: In Practice (Chapters 5-7)

    Integrated Access Project 3

    For this project, you enhance the functionality of a database for Magnificent Meals. The database

    contains a table to store meal information and another table to store order information. You add ajunction table to represent the many-to-many relationship between these tables. Next, add a subreport

    to a main report and customize the subreport in Designview. You create and modify a navigation form.

    Finally, you build and test anAutoExecmacro to open the navigation form when the database opens.

    [Student Learning Outcomes: 5.2, 5.3, 5.4, 5.5, 5.7, 6.4, 6.5, 6.7, 7.7]

    Files Needed: MagnificentMeals-03.accdb

    Completed Project File Names: [your initials] Access Project 3.accdb

    Skills Covered in this Project

    Determine the need for a many-to-many relationship.

    Create a junction table with a concatenated primary key.

    Define a relationship with the Lookup Wizard.

    View and edit relationship properties.

    Use multiple columns in a lookup field.

    Add data into a junction table.

    Add a parameter to a report.

    Add a subreport to a main report.

    Edit a report in Designview.

    Edit properties of a control in a report.

    Create a navigation form.

    Edit a form in Designview.

    Use the Macro Builder.

    Build a stand-aloneAutoExecmacro.

    Test a macro.

    1.

    Open the MagnificentMeals-03.accdbdatabase file from your student data files andsave it as[your

    initials] Access Project 3.

    2.

    If prompted, enable content in the database.

    3.

    Review the existing tables.

    a.

    Open the Mealstable in Datasheetview. Note that this table contains 11 records showing the

    individual meals that are offered for sale.

    b.

    Switch to Designview.

    c.

    Note that the Primary Keyof MenuIDis a NumberData Type, with a Field Size of Long Integer.

    d.

    Open the Orderstable in Datasheetview. Note that this table contains 12 records showing the

    details about each order placed by a customer.

    e.

    Switch to Designview.

    f.

    Note that the Primary Keyof OrderIDis a Short TextData Type, with a Field Size of 5.

    4.

    Determine the relationship type.

    a.

    A Mealcould be ordered on many different orders.

    b.

    An Ordercould have many different meals.

  • 8/10/2019 Access Integrated Project 3

    2/6

    Access 2013: In Practice Integrated Access Project 3 (Chapters 5-7) Page 2 of 6

    c.

    There is a many-to-manyrelationship between Mealsand Orders.

    d.

    Close both tables.

    5.

    Create a junction table.

    a.

    Click the Table Designbutton to open a new table in Designview.

    b.

    Enter the table fields using the information in the following table.

    c.

    Designate the MenuID-FKand the OrderID-FKfields as the concatenated primary key

    d.

    Save the table asMealOrder.

    6.

    Use the Lookup Wizardto create a one-to-many relationship between the MealOrderand Orders

    tables.

    a.

    For the OrderID-FKfield, select Lookup Wizard in the Data Typeproperty boxto create a

    relationship between the MealOrderand Orderstables.

    b.

    Include the OrderIDfield in the Selected Fields: window.

    c.

    Do not sort by any fields.d.

    Enable data integrity and restrict deletes.

    e.

    Save and close the table to ensure that the changes are saved correctly.

    7.

    Use the Lookup Wizardto create a one-to-many relationship between the MealOrderand Meals

    tables. This lookup will display multiple fields.

    a.

    Open the MealOrdertable in Designview.

    b.

    For the MenuID-FKfield, select Lookup Wizard in the Data Typeproperty boxto create a

    relationship between the MealOrderand Mealstables.

    c.

    Include the MenuIDand MealNamefields in the Selected Fields: window.

    d.

    Sort by the MealNamefield in ascending order.

    e.

    Do not hide the key column.

    f.

    Double-click the right edge of the MealNamecolumn to adjust the width of the lookup column.

    g.

    Store the MenuIDfield.

    h.

    Enable data integrity and restrict deletes.

    i.

    Save and close the table.

    8.

    Edit the relationships.

    a.

    Click the Relationshipsbutton to open the Relationshipswindow.

    Field Name Data Type Description Field Size

    OrderID-FK Short Text

    Must match an OrderID in

    the Orders table

    5

    MenuID-FK Number

    Must match a MenuID in the

    Meals table

    Long Integer

    3-ServingQty NumberNumber of 3-Serving

    portions ordered

    Byte

    6-ServingQty Number

    Number of 6-Serving

    portions ordered

    Byte

  • 8/10/2019 Access Integrated Project 3

    3/6

    Access 2013: In Practice Integrated Access Project 3 (Chapters 5-7) Page 3 of 6

    b.

    Click the Show Tablebutton to add

    the MealOrdertable into the window.

    If needed, move the tables so that the

    Relationshipswindow is similar to

    Figure 1.

    c.

    Edit the relationship between Mealsand MealOrderto cascade updates.

    d.

    Edit the relationship between Orders

    and MealOrderto cascade updates.

    e.

    Save the changes.

    f.

    Close the Relationshipswindow.

    9.

    Add the data in the following table into the MealOrderjunction table. The table shows the values in

    the additional lookup field to aid in your data entry.

    OrderID-FK MenuID-FK MealName3-Serving

    Qty

    6-Serving

    Qty

    10100 1 Savory Grilled Chicken with Sesame Honey Butter 0 1

    10100 8 Chocolate Decadence Cake 0 1

    10101 8 Chocolate Decadence Cake 0 1

    10102 2 Cheese Stuffed Turkey Burger on a Pretzel Bun 1 0

    10103 3 Southwest Pork Carnitas Wraps 1 0

    10103 4 Chipotle Maple Corn 1 0

    10103 9 Peanut Butter Cupcake 1 0

    10104 7 Seafood Cioppino 0 2

    10105 9 Peanut Butter Cupcake 0 4

    10106 7 Seafood Cioppino 1 0

    10107 2 Cheese Stuffed Turkey Burger on a Pretzel Bun 1 0

    10107 10 Almond Green Beans 1 0

    10107 11 Oatmeal Raisin Cookies 0 1

    10108 8 Chocolate Decadence Cake 0 2

    10109 7 Seafood Cioppino 1 110110 1 Savory Grilled Chicken with Sesame Honey Butter 1 0

    10110 10 Almond Green Beans 1 0

    10111 1 Savory Grilled Chicken with Sesame Honey Butter 1 1

    Figure 1 - Magnificent Meals database relationships

  • 8/10/2019 Access Integrated Project 3

    4/6

    Access 2013: In Practice Integrated Access Project 3 (Chapters 5-7) Page 4 of 6

    10.

    Save and close the table.

    11.

    Edit the OrderDetailsreport to add a parameter.

    a. Open the OrderDetailsreport in Designview. If needed, open the Property Sheet.

    b.

    Ensure that the Selection typeis set to Report.

    c.

    Open the Query Builder in the Record Sourceproperty.

    d.

    Click Yeswhen prompted to create a query based on the table.

    e.

    Add all five fields into the query grid.

    f.

    Create a flexible parameter so users can leave the parameter blank if they wish to see all of the

    orders. Enter the following text into the Criteriabox of the DeliveryDateTime field: Like "*"

    & [Enter the delivery date to search for (Leave blank to search

    for all delivery dates)] & "*"

    g.

    Save the query and close the Query Builder.

    h.

    Save the report.

    i.

    Switch to Reportview to test the changes made to the report.

    j.

    Enter 6/5/2014in the Enter Parameter Value dialog box and press OK. The report should

    show the two orders scheduled for delivery on that date.

    12.

    Add a subreport to the OrderDetailsmain report. Refer back to How To Use a Table or Query as aSubreport in a Main Reportin SLO 6.7 Using Subreportsif you need additional guidance.

    a.

    Change the OrderDetailsreport to Designview.

    b.

    Use the Subform/Subreportbutton to add a subreport onto the main report. Position the

    subreport below the existing fields near the left side of the main report.

    c.

    Verify that the Use existing Tables and Queriesbutton is selected on the first page of the

    SubReportwizard.

    d.

    On the second page of the SubReportwizard, choose the MealOrdertable and add the MenuID-

    FKfield from the MealOrdertable onto the subreport.

    e.

    Change the table selection to the Mealstable and add the MealNamefield onto the subreport.

    f.

    Change the table selection back to the MealOrdertable and add the 3-ServingQTYand 6-

    ServingQTYfields onto the subreport.

    g.

    On the third page of the SubReportwizard, accept the Choose from a listradio button and the

    defaultlinking statement.

    h.

    On the last page of the wizard, edit the suggested name for the subreport so that it reads

    MealOrderSubreport.

    i.

    Use Layoutview to verify

    that the subreport is

    correctly linked to the main

    report. When prompted,

    leave the Enter Parameter

    Dialogbox blank and pressOK. The report should look

    similar to Figure 2.

    j.

    Save and close the report.

    Save any changes if prompted.

    13.

    Edit the MealOrderSubreportin Designview.

    a.

    Open the MealOrderSubreportin Design view. If needed, open the Property Sheet.

    Figure 2Layoutview after subreport is added to main report

  • 8/10/2019 Access Integrated Project 3

    5/6

    Access 2013: In Practice Integrated Access Project 3 (Chapters 5-7) Page 5 of 6

    b.

    Select the MenuID-FKcombo box. On the Formattab, enter .35in the Widthproperty

    and .2in the Leftproperty. Select Transparentin the Border Styleproperty and Centerin the

    Text Alignproperty.

    c.

    Select the MenuID-FKlabel. On the Formattab, enterMenu ID in the Captionproperty, .6

    in the Widthproperty, and .05in the Leftproperty.

    d.

    Select the MealNametext box. On the Formattab, enter .8in the Leftproperty.e.

    Select the MealNamelabel. On the Formattab, enterMeal Name in the Captionproperty

    and .8in the Leftproperty.

    f.

    Select the 3-ServingQTYlabel. On the Formattab, enter 3-Serving QTY in the Caption

    property, .94in the Widthproperty, and 5.1in the Leftproperty.

    g.

    Select the 3-ServingQTYtext box. On the Formattab, enter.3in the Widthproperty and

    5.4in the Leftproperty. Select Centerin the Text Alignproperty.

    h.

    Select the 6-ServingQTYlabel. On the Formattab, enter 6-Serving QTY in the Caption

    property, .94in the Widthproperty, and 6.2in the Leftproperty.

    i.

    Select the 6-ServingQTYtext box. On the Formattab, enter.3in the Widthproperty and

    6.5

    in the Leftproperty. Select Centerin the Text Alignproperty.j.

    Adjust the Widthproperty of the reportto be 7.3.

    k.

    Adjust the Heightproperty of the Detail sectionto be .3.

    l.

    Save and close the subreport.

    14.

    Enhance the OrderDetailsreport and test it.

    a.

    Open the OrderDetailsreport in Designview. If needed, open the Property Sheet.

    b.

    Adjust the Widthproperty of the reportto be 7.5.

    c.

    Adjust the Heightproperty of the Detail sectionto be 2.

    d.

    Select the MealOrderSubreportsubform/subreport control. On the Formattab select

    Transparentin the Border

    Styleproperty.

    e.

    Delete theMealOrderSubreportlabel.

    f.

    Save the report.

    g.

    Change to Reportview to

    test the report. When

    prompted, enter 6/5/2014

    in the Enter Parameter Value

    dialog box and press OK.

    The report should show the

    two orders scheduled for

    delivery on that date (Figure

    3).h.

    Close the report.

    15.

    Create a navigation form.

    a.

    Create a new form using the

    Navigationbutton.

    b.

    Select the Vertical Tabs, Leftform style from the list of choices.

    c.

    Drag the MealListingsform to the [Add New]button.

    Figure 3Completed report in Reportview

  • 8/10/2019 Access Integrated Project 3

    6/6

    Access 2013: In Practice Integrated Access Project 3 (Chapters 5-7) Page 6 of 6

    d.

    Drag the OrderDetailsreport to the [Add New]button. If the Enter Parameter Valuedialog box

    opens, press Cancel.

    e.

    Save the form asMainMenu.

    16.

    Enhance the look of the MainMenuform.

    a.

    Change to Designview. If needed, open the Property Sheet.

    b.

    Edit the text of the MealListingstab so there is a space between the words (e.g. Meal Listings)and select Boldin the Font Weightproperty.

    c.

    Edit the text of the OrderDetailstab to read Order Report.

    d.

    Edit the text of the Navigation Formlabel to readMagnificent Meals.

    e.

    Delete the iconin the Form Header.

    f.

    Select the Form Headersection bar and enter#FCE6D4in the Back Colorproperty.

    g.

    Select the Meal Listingsand Order Details tabs. Enter #FCE6D4in the Back Colorproperty,

    select Solidin the Border Styleproperty, enter #F7B580in the Pressed Colorproperty,

    #000000in the Pressed

    Fore Colorproperty, and

    #595959in the Fore

    Colorproperty.

    h.

    Save and close the form.

    17.

    Test the form.

    a.

    Double-click to open the

    MainMenu form. The

    form shows the two

    navigation tabs; the Meal

    Listings tab is selected

    (Figure 4).

    b.

    Click the Order Report tab.

    When prompted, leave theEnter Parameter Dialog

    box blank and press OK.

    The report displays.

    c.

    Close the form.

    18.

    Create a stand-alone macro to open the MainMenuform

    when the database opens.

    a.

    Click the Macrobutton to open the Macro Builder.

    b.

    In the Macro Builder, enter the macro code shown in

    Figure 5.

    c.

    Save the macro asAutoExec.

    d.

    Close the macro.

    19.

    Test the macro.

    a.

    Close Access.

    b.

    Open the [your initials] Access Project 3.accdb

    database file. The database starts and opens the

    MainMenuform in Formview.

    20.

    Close the database.

    Figure 5 - CompletedAutoExecmacro

    7-4 Completed MainMenunavigation form