You are on page 1of 37

Introduction to Access Services 2010

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.

2012 Microsoft Corporation. All rights reserved.

About the Author


Author: Bio: Ravi Vridhagiri As Chief Technology Officer for OnTerra Systems, Ravi Vridhagiri is responsible for development of OnTerras new product offerings, and plays a prime role in OnTerras technology consulting commissions. He is a Microsoft-certified Technology Specialist in SharePoint application development with more than 12 years of experience in various technology solution design and project implementations. He has extensive experience in Microsoft technologies, specifically Microsoft SharePoint, Microsoft C#, .NET, and more. He also is a certified Project Management Professional (PMP). Mr. Vridhagiri earned a Bachelor of Science in Mechanical Engineering from the University of Madras in India in 1999. He went on to earn a Masters of Business Administration (with specializations in Management of Information Systems and Finance) from the Rutgers University Business School in 2009.

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

2012 Microsoft Corporation. All rights reserved.

Introduction to Access Services 2010- Lab Environment

Lab Environment
During this lab, you will work in a simulated environment with the following computers or virtual machines.

Computers and Virtual Machines Used in This Lab


Icon Computer Name DEMO2010A Description This computer is configured as a stand-alone server running Windows Server 2008 with SharePoint Server 2010, SQL Server and Visual Studio 2010.

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

Microsoft Confidential - For Internal Use Only

Introduction to Access Services 2010- Lab Overview

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.

Estimated time to complete this lab: 150 minutes

2012 Microsoft Corporation. All rights reserved.

Introduction to Access Services 2010- Exercise 1: Creating your first Access Web Database

Exercise 1: Creating your first Access Web Database


Scenario
In this exercise you will be introduced to Access Services and the concepts of Web databases that integrate with SharePoint 2010. You will create a basic Web database and publish it to SharePoint Access Services. You will also provision the permissions and security to allow users to interact and collaborate with the web database. You will learn how to implement a Conditional Split data transformation that allows you to split input data based on conditional expressions and load the data into multiple destinations. After completing this exercise, you will understand:
Task

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.

Launch Access 2010 and create a Web database

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.

Microsoft Confidential - For Internal Use Only

Introduction to Access Services 2010- Exercise 1: Creating your first Access Web Database

4.

Click the Create button. The new database will be created.

Create tables and load data

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

2012 Microsoft Corporation. All rights reserved.

Introduction to Access Services 2010- Exercise 1: Creating your first Access Web Database

Quantity Integer, CostPerUnit Currency );


10.

Click the Run button to execute the SQL Commands:

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:

Create a user interface

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

16. 17. 18.

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.

On the File tab, click Publish to Access Services:

20. 21.

Type http://intranet.contoso.com as the Server URL. Type OrdersManagement as the Site Name:

22. 23. 24.

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.

Test the Web database

25.

2012 Microsoft Corporation. All rights reserved.

Introduction to Access Services 2010- Exercise 2: Access Services as a RAD Tool

Exercise 2: Access Services as a RAD Tool


Scenario
In this exercise you will explore the new Access engine and designer for creating declarative macro logic and table-based events to build useful codeless applications that run on both the client and server. You will create a simple forms-based application and attach application logic and business rules. After completing this exercise, you will be able to: Create applications using Access Create forms for Access applications Create business rules and application logic

Task

Detailed Steps Complete these steps by connecting to the computer DEMO2010A

Create the Sales Person Table

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)

Microsoft Confidential - For Internal Use Only

Introduction to Access Services 2010- Exercise 2: Access Services as a RAD Tool

Task

Detailed Steps );

Create the Orders table

6. 7.

On the ribbon, click the Create tab. Click Table:

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.

Click Click to Add, and then click Text:

9.

Type CustomerName as the column name:

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:

2012 Microsoft Corporation. All rights reserved.

Introduction to Access Services 2010- Exercise 2: Access Services as a RAD Tool

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.

Microsoft Confidential - For Internal Use Only

Introduction to Access Services 2010- Exercise 2: Access Services as a RAD Tool

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.

Design the navigation form

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:

Design the landing page form.

24.

25.

A new blank form will open up in Designer. This form will be the landing page

10

2012 Microsoft Corporation. All rights reserved.

Introduction to Access Services 2010- Exercise 2: Access Services as a RAD Tool

Task

Detailed Steps for the web database.


26. 27.

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.

Create the Orders, Products and Sales Person forms

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.

Finalize the Web user interface

32. 33.

34.

Change the text in the tabs to display as follows:

35. 36. 37. 38.

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.

Introduction to Access Services 2010- Exercise 2: Access Services as a RAD Tool

Task rules Rule 1: A single order cannot exceed 5 quantities of any product

Detailed Steps View:

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.

From the Add New Action drop-down list, select Messagebox.

12

2012 Microsoft Corporation. All rights reserved.

Introduction to Access Services 2010- Exercise 2: Access Services as a RAD Tool

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.

From the Add New Action drop-down list, select GoToControl:

48.

Type QuantityOrdered as the Control Name:

49.

The completed macro should resemble the following:

50.

Save and Close the macro.

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

Microsoft Confidential - For Internal Use Only

Introduction to Access Services 2010- Exercise 2: Access Services as a RAD Tool

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.

55. 56. 57.

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

58. 59. 60.

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

2012 Microsoft Corporation. All rights reserved.

Introduction to Access Services 2010- Exercise 2: Access Services as a RAD Tool

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

Microsoft Confidential - For Internal Use Only

Introduction to Access Services 2010- Exercise 2: Access Services as a RAD Tool

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.

Finalize and test the application

63. 64.

65.

16

2012 Microsoft Corporation. All rights reserved.

Introduction to Access Services 2010- Exercise 3: Macros

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

Detailed Steps Complete these steps by connecting to the computer DEMO2010A

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.

On the ribbon, click Table:

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

Introduction to Access Services 2010- Exercise 3: Macros

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.

Similarly add another SetLocalVar action to read the order quantity:

12.

Create a look up the Products table and query the "Quantity" (the current

18

2012 Microsoft Corporation. All rights reserved.

Introduction to Access Services 2010- Exercise 3: Macros

Task

Detailed Steps inventory level) for the selected product (_Product). a. From the drop-down list, select LookUpRecord:

b.

The LookUpRecord action block should appear as follows:

c.

Set the lookup condition as follows:

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

Microsoft Confidential - For Internal Use Only

Introduction to Access Services 2010- Exercise 3: Macros

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)

Add a RaiseError action. Set the error information as follows:

f.

The completed look-up block should now resemble the following:

13.

The completed macro should resemble the following:

20

2012 Microsoft Corporation. All rights reserved.

Introduction to Access Services 2010- Exercise 3: Macros

Task

Detailed Steps

14. 15. 16.

Save the macro. Save the Orders table. Save the Database.

NOTE: The steps 17 to 26 are Optional


17.

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.

On the ribbon, under Table Tools, click Table:

21

Microsoft Confidential - For Internal Use Only

Introduction to Access Services 2010- Exercise 3: Macros

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.

Set the lookup condition as follows:

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

2012 Microsoft Corporation. All rights reserved.

Introduction to Access Services 2010- Exercise 3: Macros

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.

Set the Name and the Value as follows:

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

Microsoft Confidential - For Internal Use Only

Introduction to Access Services 2010- Exercise 3: Macros

Task

Detailed Steps

Finalize and test the application

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

2012 Microsoft Corporation. All rights reserved.

Introduction to Access Services 2010- Exercise 4: Creating Web Reports with Access Services

Exercise 4: Creating Web Reports with Access Services


Scenario
In this exercise you will explore the Access Web reports and the process of reporting the rolled-up data from the Web database tables to a SharePoint site. You will use the query designer to create queries that drive the reports. After completing this exercise, you will be able to: Create basic queries Create reports from queries Create a Report Center to display Web reports

Task

Detailed Steps Complete these steps by connecting to the computer DEMO2010A

Create a query for the order status report

1.

On the ribbon, on the Create tab, click Query:

A popup window displays all the tables in the database.


2.

From the Show Table dialog box, select all three tables. Click Add:

25

Microsoft Confidential - For Internal Use Only

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

2012 Microsoft Corporation. All rights reserved.

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.

Save the query as OrderStatus:

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

Microsoft Confidential - For Internal Use Only

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:

Create the reports form

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

2012 Microsoft Corporation. All rights reserved.

Introduction to Access Services 2010- Exercise 4: Creating Web Reports with Access Services

Task

Detailed Steps

Customizing the query output

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

Microsoft Confidential - For Internal Use Only

Introduction to Access Services 2010- Exercise 4: Creating Web Reports with Access Services

Task

Detailed Steps

Create the Report Center

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

2012 Microsoft Corporation. All rights reserved.

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:

Add the report centre to the Navigation form

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

Detailed Steps published earlier.


28.

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.

You have now completed this lab.

32

2012 Microsoft Corporation. All rights reserved.

Introduction to Access Services 2010- Appendix

Appendix
Labcode Manual Version Version 7 Last Update 12/8/2010 6:38:00 PM

Lab Notes
Description Details

Virtual Machine Requirements


Virtual Machine Name Details

33

Microsoft Confidential - For Internal Use Only

You might also like