Académique Documents
Professionnel Documents
Culture Documents
Hands-on Lab
Released:
Terms of Use
This document is provided as-is. Information and views expressed in this document, including URL and other Internet Web site references, may change without notice. You bear the risk of using it. Some examples depicted herein are provided for illustration only and are fictitious. No real association or connection is intended or should be inferred. This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You may copy and use this document for your internal, reference purposes. 2011 Microsoft Corporation. All rights reserved.
This document reflects current views and assumptions as of the date of development and is subject to change. Actual and future results and trends may differ materially from any forward-looking statements. Microsoft assumes no responsibility for errors or omissions in the materials. THIS DOCUMENT IS FOR INFORMATIONAL AND TRAINING PURPOSES ONLY AND IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
Contents
Lab Environment ..............................................................................................................................................................1 Lab Overview......................................................................................................................................................................2 Exercise 1: Creating your first Access Web Database .......................................................................................3 Exercise 2: Access Services as a RAD Tool .............................................................................................................7 Exercise 3: Macros ........................................................................................................................................................ 17 Exercise 4: Creating Web Reports with Access Services ............................................................................... 25 Appendix ........................................................................................................................................................................... 33
Lab Environment
During this lab, you will work in a simulated environment with the following computers or virtual machines.
Logon Credentials
The lab environment might require you to log on to the Hands-on Lab Environment using the following credentials, unless specified differently throughout the lab manual.
Username Administrator Password pass@word1
Lab Overview
Abstract
Access Services is a service application available in Microsoft SharePoint Server 2010 that allows users to edit, update, and create linked Microsoft Access 2010 databases that can be viewed and manipulated by using an internet browser, the Access client, or a linked HTML page. During this lab, you will perform several exercises to achieve a better understanding of the capabilities and functionality of Access Services in SharePoint 2010. You will start with basic exercises of understanding Microsoft Access as a SharePoint service application and create basic web databases. You will then use Access as a rapid application development (RAD) tool to create business applications, publish them as web databases to SharePoint, and collaborate with other users. You will also work with macros to create simple business rules. By the end of these series you will have designed reports and presented rolled-up data from the web database as reports within a SharePoint site.
Learning Objectives
After completing the exercises in this lab, you will be able to: Create a Web database using Microsoft Access and host it in a SharePoint site Use Access 2010 as a rapid application development (RAD) tool to create web applications and deliver it via SharePoint. Use macros to attach application logic and business rules to the web database and to the Access applications. Create and publish reports.
Introduction to Access Services 2010- Exercise 1: Creating your first Access Web Database
How to create a Web database using Access 2010 How to publish the Web database to SharePoint and share it with other users. How to configure the security of the Web database.
Detailed Steps Complete these steps by connecting to the computer DEMO2010A.
1. 2.
Click Start | All Programs | Microsoft Office | Microsoft Access 2010 menu. From the File menu, under New, select Blank Web Database from the list of Available Templates. Under File Name, type OrdersManagement and select a path to save the database to:
3.
Introduction to Access Services 2010- Exercise 1: Creating your first Access Web Database
4.
5. 6.
On the ribbon, click the Create tab. Under Client Queries, select Query Design:
There are several ways to add Tables to an Access database: 1. Import Tables and Data 2. Create Tables (using Access designer or Query) You can import a table from another Access database, an Excel workbook, a SharePoint list, or from other ODBC sources (such as SQL Server). In this exercise, you will create a table using Transact-SQL commands.
7. 8.
Close the Show Table dialog box. Right-click the query window and select SQL View:
.
9.
Copy and paste the following SQL command into the query editor: CREATE TABLE ( ID int PRIMARY KEY, ProductName CHAR(25), ProductDescription CHAR(100), Products
Introduction to Access Services 2010- Exercise 1: Creating your first Access Web Database
11. 12.
The Products table is created. Close the query window. If prompted to save, click No. You need to create a form (User Interface) for the users to interact with the "Products" table. To create the form, select the Products table. On the ribbon, on the Create tab, click Form:
13.
14.
A default form is created. This form will have all the fields in the Products table. Click the Save button to save this form. Type ProductsForm in the Save As dialog box, and then click OK:
15.
Set up the default forms for the database A default form is the
5
On the File Tab, click Options. From the list of available options in the left pane, select Current Database. Under Application Options, set the Display Form and Web Display Form to ProductsForm. Click OK
Microsoft Confidential - For Internal Use Only
Introduction to Access Services 2010- Exercise 1: Creating your first Access Web Database
one that is displayed in the landing page of the SharePoint site hosting the database. Publish the database to the SharePoint site
19.
20. 21.
Type http://intranet.contoso.com as the Server URL. Type OrdersManagement as the Site Name:
Click the Publish to Access Services button. The Access database is published to SharePoint. Open an Internet Explorer browser window and navigate to http://intranet.contoso.com/OrdersManagement, the Access Web database site. The Access Web database is created, and you should see the Products table and the Products form. You can now create, retrieve, update and delete records in the Products table.
25.
Task
1. 2.
In Access 2010, on the ribbon, click the Create tab. Under Client Queries, select Query Design:
The Sales Person Table, as the name suggests, contains information about sales people. In this scenario, every order that is placed is assumed to be sold by a sales person. Sales person information is stored in a separate table and is linked to the Order table through a look-up.
3. 4. 5.
Close the Show Table dialog box. Right-click query window and select SQL View. Copy and paste the following SQL command and execute it to create the SalesPerson table: CREATE TABLE SalesPerson ( ID int PRIMARY KEY, SalesPersonName char(25), SalesPersonAddress char(100)
Task
Detailed Steps );
6. 7.
The Orders table, as the name suggests, contains order information. In our scenario every order that is placed is for one type of product. The products are stored in the Products table.
8.
9.
Note: the first column [ID] is the primary key. Retain this column as it is.
10. 11.
Similarly, create the second column CustomerAddress of type Text. Click Click to Add, and then click Lookup & Relationship:
Task
Detailed Steps
a. b. c. d. e. f.
In the Lookup wizard, select I want to lookup a field to get the values from another table. Click Next. Select Products. Click Next. From the Available Fields, select ProductName and click the button to move ProductName to Selected Fields. Click Next. Select ProductName in the first drop-down. Click Next. Click Next. For the lookup field name, type ProductOrdered. Leave the checkboxes Enable Data Integrity and Allow Multiple Values unchecked. Click Finish.
g.
12.
Click Click to Add, and create the fourth column OrderQuantity of type Number. In the same way that you created the look-up to the Products table, create a look-up to the Sales Person table. Set the name of this column to SalesPerson. Click Click to Add, and then click Lookup & Relationship. In the Lookup wizard, select I will type in the values that I want, and then click Next:
13.
14. 15.
Task
Detailed Steps 16. Set the Number of columns to 1, and add Order Placed, Order Processed and Order Shipped as row items to the list:
Click Next.
17.
Set the name of the field to OrderStatus. Leave the checkboxes Limit To List and Allow Multiple Values unchecked. Click Finish. Set the default value to Order Placed. On the ribbon, click the Create tab. Under Navigation, select Horizontal Tabs:
18. 19.
20. 21.
22.
Click on the header (Title) and change the text Navigation Form to Order Management System:
23.
Save this form as NavigationForm. On the ribbon, click the Create tab, and then click Blank Form:
24.
25.
A new blank form will open up in Designer. This form will be the landing page
10
Task
From the Design tab on the ribbon, add a Label control to this form. Type "WELCOME TO CONTOSO'S ORDER MANAGEMENT SYSTEM". You can set the font size and formatting from the Label's Properties Save this form as SplashForm:
28.
29.
On the left pane, in the All Access objects section, under Tables, select the Orders table. On the ribbon, on the Create tab, click Form. This will create a new form with the fields from the Orders Table. Save this form as OrdersForm. Similarly, create a form named ProductsForm from the Products table and a form named SalesPersonForm from the SalesPersons table. On the left pane, right-click NavigationForm and select Layout View. Drag each form from the left pane (under Forms) to the Tabs section of the NavigationForm:
30.
31.
32. 33.
34.
Save the NavigationForm. As explained in Exercise 1, set the Web Display Form to NavigationForm. Save the database. Click the Sync button to sync up the changes to the already published Web database. Open an Internet Explorer browser window and navigate to the OrdersManagement Access Web database. View and test the Web forms. On the left pane, under Forms, right-click OrdersForm and then click Layout
Microsoft Confidential - For Internal Use Only
39.
Create business
11
40.
Task rules Rule 1: A single order cannot exceed 5 quantities of any product
41. 42.
Right-click the textbox OrderQuantity and then click Properties. In the Property Sheet, click the Event tab:
43.
Click the field After Update. Click on the button next to the drop-down menu button. This will launch the Macro Tools and the Macro designer:
44.
From the drop-down list, select the IF condition and set the condition to [QuantityOrdered]>5:
45.
12
Task
Detailed Steps 46. Type You cannot order more than 5 items in a single order as the message. The macro logic block should resemble the following:
47.
48.
49.
50.
NOTE: The steps 51 to 62 are Optional Rule 2: Users should not be able to delete any records from the Orders form
51. 52. 53.
From the Property Sheet, select Form from the drop-down list. Select the Data tab. Set Allow Deletions to No:
13
Task
Detailed Steps
54.
Save the form. From the Property Sheet, select Form from the drop-down list Select the Event tab. Click the field On Current. Click on the button next to the drop-down button. This will launch the Macro Tools:
Rule 3: Once the order is placed, only the Order Status can be changed.
An order is placed when the ID (The primary key field) is a valid number. By checking the value of the ID, we can determine if the form is in "Insert Mode" or in "Edit Mode". If the Form is in Edit Mode, we need to disable all but the "Order Status" fields
Add an IF condition to check for [ID]>0. Add 6 SetProperty actions. As shown in the figure below, set the Enabled property of the OrderStatus control to true, and set the Enabled property of every other control to false:
14
Task
Detailed Steps
61.
Insert an Else Block. Set the Enabled property of the OrderStatus control to false, and set the Enabled property of every other control to true:
15
Task
Detailed Steps
62.
Save the changes to the macro. Save the database. Click the Sync button to synchronize the changes with the already published web database. Launch the SharePoint site to view the Web forms and the Web application. Test the business rules.
63. 64.
65.
16
Exercise 3: Macros
Scenario
In this exercise you will learn about the Access macros. You will use macros to validate the order and process the inventory. The application logic in this exercise is: When a new order is placed, the order quantity should be validated against the inventory level. The condition here is that the number of items ordered should not be more than the quantity in hand. Secondly, when an order is placed, the Products table should be updated with the remaining number of products in the inventory. After completing this exercise, you will be able to: Create UI macros and data macros Use the macro designer Customize the "Before Change" and "After Insert" events (Also called Triggers)
Task
Validate the order quantity using the Before Change builtin macro
1.
On the left pane, under Tables, double-click on the Orders table to open it:
2.
3. 4. 5.
Click Before Change. From the drop-down list, select IF. Set the IF condition to [IsInsert]:
Microsoft Confidential - For Internal Use Only
17
Task
Detailed Steps
6.
You need to read the values for "Product Ordered" and "Quantity Ordered" from the Orders Form and store them in local variables. Declare two variables named _Product and _QtyOrdered. From the Add New Action drop-down list, select SetLocalVar. Type _Product as the Name of the variable. For the expression field, click the builder icon ( ).
7. 8. 9.
IsInsert is a built-in function that specifies if the Item is being Inserted or Updated. In this scenario, we want to validate the data only before an Item in Inserted.
10.
In the expression builder, select Orders. Click ProductOrdered, and then click OK:
Alternatively, you can directly type ProductOrdered in the Expression field. The IntelliSense will display possible values for the field that you can choose.
11.
12.
Create a look up the Products table and query the "Quantity" (the current
18
Task
Detailed Steps inventory level) for the selected product (_Product). a. From the drop-down list, select LookUpRecord:
b.
c.
The Product_A alias represents the record set obtained from querying the Products table for the selected product. d. Add a new action to fetch the quantity from the Products_A record set. Store it in a local variable named _QtyInHand:
Note: This new action block should be nested within the look-up block
19
Task
Detailed Steps e. From the Add New Action dropdown, select an IF action. Set the IF condition as follows: (Note: The IF action block should also be nested inside the Look-up block)
f.
13.
20
Task
Detailed Steps
Save the macro. Save the Orders table. Save the Database.
Update the Products table using the After Insert built-in macro
On the left pane, under Tables, double-click on the Orders table to open it:
18.
21
Task
Detailed Steps
19. 20.
Click After Insert. In the same way you fetched the Product Ordered and Order Quantity from the Orders form in the previous task, fetch these values and store them in local variables named _Product and _QtyOrdered:
21.
The next step is to query the Products table for the selected product (_Product). a. Add a new LookUpRecord action.
b.
The Product_A alias represents the record set obtained from querying the Products table for the selected product.
22.
From the Add New Action drop-down list, select EditRecord action. The action should be nested inside the Look up action block:
22
Task
Detailed Steps
23.
The createalias Products_A contains the record that needs to be edited. In the EditRecord Block, in the Alias field, type Products_A. From the Add New Action drop-down list, select SetField:
24.
25.
In this step, you are setting the value of the Quantity (inventory level) to Available Quantity - the Ordered Quantity. 26. The completed macro should resemble the following:
23
Task
Detailed Steps
27. 28.
Click the Save icon to save the macros and the database. Click the Sync button to synchronize the changes with the Web database you published earlier. Launch an Internet Explorer browser window and navigate to the OrdersManagement SharePoint site to view the Web forms and the Web application. Test the business rules that you created in the exercise.
29.
30.
24
Introduction to Access Services 2010- Exercise 4: Creating Web Reports with Access Services
Task
1.
From the Show Table dialog box, select all three tables. Click Add:
25
Introduction to Access Services 2010- Exercise 4: Creating Web Reports with Access Services
Task
Detailed Steps
3.
Select the tables and the fields needed for reports. The fields can be selected from the bottom pane of the query editor window.
4.
To arrange records of the field in ascending/descending order select either of the options as shown. To show the fields value in the query result, check the checkbox below each field.
26
Introduction to Access Services 2010- Exercise 4: Creating Web Reports with Access Services
Task
Detailed Steps
5.
After selecting the fields the query window should look as follows:
6.
NOTE: The steps 7 to 17 are Optional Create query for the sales person report.
7.
Repeat the steps to create another query for the Sales Persons report. After adding the 3 tables to the query, select the columns from the tables as shown. Create a column in the query window called Amount. This is a calculated field: Amount:[CostPerUnit]*[QuantityOrdered]
27
Introduction to Access Services 2010- Exercise 4: Creating Web Reports with Access Services
Task
Detailed Steps
8.
Save the query as SalesPersonBusiness. On the left pane, in the All Access Objects section, under Queries, select OrderStatus. On the ribbon, on the Create tab, select Report:
9.
10.
Reports forms are forms created from the queries. The output of the queries are either displayed directly or customized (grouped or ordered by) and presented to the end-users via report forms.
11. 12.
A new report form will be created from the OrderStatus query. This report is intended to show products grouped by order status. Select the OrderStatus and field, and then select Group on OrderStatus.
13. 14.
Save the report as Order Status Report. Similarly, repeat the above steps to create a Sales Person Business Report from the SalesPersonBusiness query. In this report, create a grouping on the SalesPersonName field
28
Introduction to Access Services 2010- Exercise 4: Creating Web Reports with Access Services
Task
Detailed Steps
15.
To calculate and display the total sales, right-click the TotalCostPerUnit field and choose the Sum function:
16. 17.
Click the Save button to save the reports and the database. You should be able to see both the reports in the left pane under the Reports heading:
29
Introduction to Access Services 2010- Exercise 4: Creating Web Reports with Access Services
Task
Detailed Steps
18.
On the ribbon, under the Create tab, select Blank Form. A new blank form will be created.
19.
From the Design tab, select the Label control and add it to the form. Set the text in the label to Reports Center. Right-click the label and select Properties. Set the font size to 18 (or a size of your choice):
20.
30
Introduction to Access Services 2010- Exercise 4: Creating Web Reports with Access Services
Task
Detailed Steps
21.
On the ribbon, on the Design tab, click the Navigation button to create a navigation control. Drag each report to the navigation control you created earlier:
22.
23.
Click the Save button to save the Report Center form. From the left pane, in the Forms section, right-click NavigationForm, and then select Layout View:
24.
25.
Select the Report Center form and drag it to the navigation form. The navigation form should now resemble the following:
26. 27. 31
Click the Save button to save all open forms to the database. Click the Sync button to synchronize the changes with the Web database you
Microsoft Confidential - For Internal Use Only
Introduction to Access Services 2010- Exercise 4: Creating Web Reports with Access Services
Task
Launch an Internet Explorer browser window and navigate to the OrdersManagement SharePoint site (http://intranet.contoso.com/ordermanagement) to view the Reports center and the reports.
32
Appendix
Labcode Manual Version Version 7 Last Update 12/8/2010 6:38:00 PM
Lab Notes
Description Details
33