Microsoft Office Access 2013 Tutorial Part 2 An Introduction to Access 2013 Creating Reports and Forms for Tables Author Sandra Dyke https://sites.google.com/site/sandrascourses/ This work is licensed under the Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/
Contents Page Introduction... 3 Reports... 4 Create a Report... 4 Report 1: Customer Phone List... 4 Other Views... 7 Formatting Reports... 8 Which View to use: Design or Layout?... 11 Report 2: Creating an Employee Sales Report... 13 Adding New Fields to the Report... 20 Create Reports from Queries... 25 Forms... 26 Creating Forms for Tables... 26 Form 1: Creating a Customer Form... 26 Using Lookups on a Form... 27 Form 2: Sale entry... 27
Introduction This tutorial looks at creating forms and reports and carries on from Part 1 which created the Basic Sales System database. This is the relationship between the tables: It allows a sale to contain just 1 inventory item. The database rules are: 1 sale must relate to 1 customer 1 customer may have many sales 1 sale must relate to 1 inventory item 1 inventory item may relate to many sales 1 sale must relate to 1 employee 1 employee may have many sales Sandra Dyke, 2015 3 Access 2013 Tutorial Part 2
Reports Reports are used to view information in the database. They can be created using a wizard or manually and they can be modified to display the information in different ways. This tutorial will only use the Report Wizard and making modifications to this. Reports can be based on tables or on queries. Create a Report Select Create Report Wizard Follow the instructions in the wizard to select the table or query and the desired fields. The fields will be shown in the report in the order in which they are selected but they can be moved around later. Report 1: Customer Phone List From the Tables/Queries drop down list select the Customer table From the Available Fields list select CustomerFirstName CustomerLastName CustomerPhoneNumber Click Next Ignore the grouping option at this stage Click Next Sandra Dyke, 2015 4 Access 2013 Tutorial Part 2
Sort the report first by CustomerLastName and then by CustomerFirstName Click Next Select a report layout (this example will use the tabular layout) and Orientation (portrait) Click Next Give the report a suitable name (eg Customer Phone List) Click Finish Sandra Dyke, 2015 5 Access 2013 Tutorial Part 2
Preview the report. When the preview is closed, the report is shown in the Design View Mode where alterations can be made to the formatting of the report. Parts of the report Sandra Dyke, 2015 6 Access 2013 Tutorial Part 2
Other Views Layout View Print Preview Sandra Dyke, 2015 7 Access 2013 Tutorial Part 2
Formatting Reports Let s have a look at the formatting of the report. The heading looks okay, but it would be better if it was centred. The column headings are the table captions so they are probably okay but if there were no captions they will be the table attributes and will be in CamelCase. They also include the word Customer in each one. A better format for the column headings would be to delete the word Customer from each heading and to put a space between the words. Report where captions were available: Same report where captions were not available In Design View, the report is broken into a number of sections: Report header what is printed on the first page of the report Page header what is printed on the top of each page o Text in these areas tend to be just headings and can easily be adjusted. Details section is linked to the database table and fields. o These can also be modified by changing their placement and the size of the fields can be changed to display all of the data. Page footer shows what is printed on the bottom of each page o Eg the date (=Now()) and the page number. Sandra Dyke, 2015 8 Access 2013 Tutorial Part 2
There are 2 ways to centre the report header. First the textbox containing the heading can be moved and manually centred. Alternatively, the width of the textbox can be changed to the width of the page and then the text can be centred. Select the textbox Click on the middle dot on the right of the textbox and drag it to the edge of the page Click inside the textbox and then click the centre button (on the Format Tab). Result Sandra Dyke, 2015 9 Access 2013 Tutorial Part 2
Adjusting the column headings if needed Click inside the textbox, delete the word Customer and put a space between Last and Name Do not change any of the text in the details section. If you do, the report will no longer display the required information in the report. The text in the Detail section refers to the field names in the database. Switch to Report View Mode Final Version Sandra Dyke, 2015 10 Access 2013 Tutorial Part 2
Which View to use: Design or Layout? Most adjustments that can be made in the Design View can also be made in the Layout View but the Layout view makes it easier to see what the final report will look like with the report details included Switch to the Layout View Change the headings to Bold Click on Last Name Click on Bold Repeat for the rest of the headings Sandra Dyke, 2015 11 Access 2013 Tutorial Part 2
Remove the alternate row colour Select the report details Use the Alternate Row Color options Sandra Dyke, 2015 12 Access 2013 Tutorial Part 2
Report 2: Creating an Employee Sales Report Using the Report Wizard, select the table Sale and select the following fields. This time, the report is going to group all of the sales by Employee ID Click Next Sort by SaleDate Sandra Dyke, 2015 13 Access 2013 Tutorial Part 2
Let s sum by the quantity for each inventory item. Click on Summary Options and select Sum for SaleQuantity Click OK Click Next Select the Stepped layout and change the orientation to landscape Click Next Give the report a suitable title (eg Sale By Employee ID) Click Finish Change to Report View Sandra Dyke, 2015 14 Access 2013 Tutorial Part 2
Now, the report is not the nicest. Switch to the Design View mode and modify the report format to look like the following: Sandra Dyke, 2015 15 Access 2013 Tutorial Part 2
The report has some of the same features as before but now there are some new ones: EmployeeID Header this allows the data to be sorted by Employee ID EmployeeID Footer contains the total number of items sold Report Footer contains the total quantity sold by all employees Sandra Dyke, 2015 16 Access 2013 Tutorial Part 2
Step 1: Put each employee s details on separate pages Click the property sheet to open it Click on the EmployeeID Header to select it and change Force New Page in the Property Sheet to Before Section Switch to Print Preview (separate pages only show up in print preview, not report view) Sandra Dyke, 2015 17 Access 2013 Tutorial Part 2
Now each employee is on a separate page with the grand total on the last page. The label isn t really so delete it Go to Design View Click on the label to be deleted and click delete on the keyboard Other changes to make The employee ID number is difficult to read so click on the text box and change its format to left justification The label Sum isn t very meaningful so click on it and change it to Total Sold Sandra Dyke, 2015 18 Access 2013 Tutorial Part 2
The border around the total quantity sold looks strange so remove it by clicking on it (in Design View) and use the property sheet to change the settings. While we are at it, let s make the number bold. Control Source shows the formula used to make the calculation Border Style change this to transparent to make it disappear Font Weight change the format of the text to Bold Sandra Dyke, 2015 19 Access 2013 Tutorial Part 2
Adding New Fields to the Report We notice that there is no information about the inventory item sold Click on Add Existing Fields Drag the Inventory ID into the Page Header To change the layout click Tabular on the Arrange tab Sandra Dyke, 2015 20 Access 2013 Tutorial Part 2
Move both parts to a suitable position Click Remove Layout Now the InventoryID text box in the Detail section can be lined up with the rest of the headings. The arrange tab has an Align option which might be useful select another textbox which is in the correct position first and then click the InventoryID text box and align to the top Sandra Dyke, 2015 21 Access 2013 Tutorial Part 2
Looking at the report we decide to calculate the value of sales for each item Click on the Text Box button in the Controls section of the Design tab Draw a Text Box in a suitable position. Notice that a label is also added. Open the Property Sheet Name the field TotalSaleValue To add the formula Click on the 3 dots to open the Expression Builder in the Control Source field Sandra Dyke, 2015 22 Access 2013 Tutorial Part 2
Select the report we are working on in the Expression Elements box Click SaleQuantity in the Expression Category Add the multiplication symbol (same as for Excel) * Click on SaleUnitPrice Click OK Switch to Page View Sandra Dyke, 2015 23 Access 2013 Tutorial Part 2
Switch back to Design View and make the following changes in the Property Sheet Rearrange the label and text box Give the label a caption Add another Text Box to the EmployeeID Footer to calculate the total sales value for each employee Use the expression builder to calculate the total sales value for each employee and format it suitably Delete the label with Text35 by clicking on the label so it is selected by itself and click delete Sandra Dyke, 2015 24 Access 2013 Tutorial Part 2
Tidy up the report formatting to make it look good. Final Version in Report View Create Reports from Queries Choose a query instead of a table to create a report based on a query/ Sandra Dyke, 2015 25 Access 2013 Tutorial Part 2
Forms A form can be used to view, add, edit and delete data. Forms can be formatted in a way which is useful for the user. Creating Forms for Tables The easiest way to create a data entry form is to use the Form button Select the table required Click Create Form Form 1: Creating a Customer Form First select the Customer table Then Click the Form button This produces a form including all of the data entry fields. Any related records in the Sale table are also shown, making it easy to add, edit or delete these records. Each Customer record can be displayed and new records added. Save the form as Update Customer Table Sandra Dyke, 2015 26 Access 2013 Tutorial Part 2
Using Lookups on a Form Form 2: Sale entry Create a form for the Sale table called Update Sale Table At the moment this is not very useful because the only data captured are ID numbers. To improve this form, the Sale table could be modified to include lookup lists for customer, inventory, and employee to help the user to capture the correct information. Steps 1. Right click on the Sale table in navigation pane and select copy and rename it 2. Paste the Sale table and rename it 3. Choose the structure and data option 4. Change the CusotmerID field to a lookup list (see below) 5. Do the same for InventoryID and EmployeeID 6. Create a form to input the sale data (fsale2) 7. Change the SaleID to a read only field because this is an auto number field (see below) Sandra Dyke, 2015 27 Access 2013 Tutorial Part 2
Change the CustomerID field to a lookup list: In design view change the Data Type to Lookup Wizard Work through the Lookup Wizard Sandra Dyke, 2015 28 Access 2013 Tutorial Part 2
Untick the Hide Key Column if you forget that is okay it can be fixed later Sandra Dyke, 2015 29 Access 2013 Tutorial Part 2
Click on Lookup in the Field Properties section Check that the Lookup properties are as shown below if the first column width is 0cm, change it to 2.542cm to make the first column show in the dropdown list Repeat for Inventory ID and Employee ID Create a form for this table Sandra Dyke, 2015 30 Access 2013 Tutorial Part 2
To disable the SaleID Click on SaleID textbox Open the Property Sheet Select the Data tab Change Enabled to No Form with lookup list Customer Lookup list NB If you use a form to update a table, the table needs to be closed for the update to be shown. Sandra Dyke, 2015 31 Access 2013 Tutorial Part 2