MS Access About the Tutorial Microsoft Access is a Database Management System (DBMS) from Microsoft that combines the relational Microsoft Jet Database Engine with a graphical user interface and software- development tools. It is a part of the Microsoft Office suite of applications, included in the professional and higher editions. This is an introductory tutorial that covers the basics of MS Access. Audience This tutorial is designed for those people who want to learn how to start working with Microsoft Access. After completing this tutorial, you will have a better understating of MS Access and how you can use it to store and retrieve data. Prerequisites It is a simple and easy-to-understand tutorial. There are no set prerequisites as such, and it should be useful for any beginner who want acquire knowledge on MS Access. However it will definitely help if you are aware of some basic concepts of a database, especially RDBMS concepts. Copyright and Disclaimer Copyright 2018 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at [email protected]. i MS Access Table of Contents About the Tutorial .................................................................................................................................. i Audience ................................................................................................................................................ i Prerequisites .......................................................................................................................................... i Copyright and Disclaimer ........................................................................................................................ i Table of Contents .................................................................................................................................. ii 1. MS ACCESS – OVERVIEW .................................................................................................... 1 2. MS ACCESS – RDBMS ......................................................................................................... 3 Data Definition ...................................................................................................................................... 3 Data Manipulation ................................................................................................................................ 4 Data Control .......................................................................................................................................... 4 3. MS ACCESS — OBJECTS ...................................................................................................... 5 Table ..................................................................................................................................................... 5 Query .................................................................................................................................................... 5 Form ...................................................................................................................................................... 6 Report ................................................................................................................................................... 6 Other MS Access Objects ....................................................................................................................... 6 4. MS ACCESS — CREATE DATABASE ...................................................................................... 8 Create Blank Database ........................................................................................................................ 12 5. MS ACCESS — DATA TYPES .............................................................................................. 14 6. MS ACCESS — CREATE TABLES ......................................................................................... 16 Table Design View ............................................................................................................................... 21 7. MS ACCESS – ADDING DATA ............................................................................................ 28 ii MS Access 8. MS ACCESS — QUERY DATA ............................................................................................. 31 Create Select Query ............................................................................................................................. 31 9. MS ACCESS — QUERY CRITERIA ....................................................................................... 35 10. MS ACCESS — ACTION QUERIES ...................................................................................... 41 Create an Append Query ..................................................................................................................... 41 11. MS ACCESS — CREATE QUERIES....................................................................................... 48 Create an Update Query ...................................................................................................................... 48 Create a Delete Query ......................................................................................................................... 50 Create a Make Table Query ................................................................................................................. 53 12. MS ACCESS — PARAMETER QUERIES ............................................................................... 58 13. MS ACCESS — ALTERNATE CRITERIA ................................................................................ 62 14. MS ACCESS — RELATING DATA ........................................................................................ 66 Normalization ...................................................................................................................................... 66 Defining Relationships ......................................................................................................................... 67 15. MS ACCESS — CREATE RELATIONSHIPS ............................................................................ 69 Why Create Table Relationships? ........................................................................................................ 69 16. MS ACCESS — ONE-TO-ONE RELATIONSHIP ..................................................................... 72 17. MS ACCESS — ONE-TO-MANY RELATIONSHIP .................................................................. 77 18. MS ACCESS — MANY-TO-MANY RELATIONSHIP ............................................................... 82 iii MS Access 19. MS ACCESS — WILDCARDS .............................................................................................. 89 ANSI-89 wildcard characters ................................................................................................................ 89 ANSI-92 wildcard characters ................................................................................................................ 90 20. MS ACCESS — CALCULATED EXPRESSION ........................................................................ 99 21. MS ACCESS — INDEXING ................................................................................................ 103 22. MS ACCESS — GROUPING DATA .................................................................................... 108 Aggregate Query ............................................................................................................................... 108 Concatenation in Access .................................................................................................................... 112 23. MS ACCESS — SUMMARIZING DATA .............................................................................. 117 24. MS ACCESS — JOINS ...................................................................................................... 122 What is Join ....................................................................................................................................... 122 Left Outer Join & Right Outer Join ..................................................................................................... 123 Self-Joins ........................................................................................................................................... 129 25. MS ACCESS — DUPLICATES QUERY WIZARD .................................................................. 135 26. MS ACCESS — UNMATCHED QUERY WIZARD ................................................................ 143 27. MS ACCESS — CREATE A FORM ..................................................................................... 150 Types of Bound Forms ....................................................................................................................... 150 Creating Forms .................................................................................................................................. 151 Multiple Item Form ........................................................................................................................... 161 Split Form .......................................................................................................................................... 163 iv MS Access 28. MS ACCESS — MODIFY A FORM ..................................................................................... 164 Controls ............................................................................................................................................. 164 Themes .............................................................................................................................................. 168 29. MS ACCESS — NAVIGATION FORM ................................................................................ 175 30. MS ACCESS — COMBO BOX ........................................................................................... 181 Combo Box ........................................................................................................................................ 181 31. MS ACCESS — SQL VIEW ................................................................................................ 190 32. MS ACCESS — FORMATTING .......................................................................................... 195 33. MS ACCESS — CONTROLS AND PROPERTIES .................................................................. 206 Bound Controls .................................................................................................................................. 206 Unbound Controls ............................................................................................................................. 206 Control Types .................................................................................................................................... 206 34. MS ACCESS — REPORTS BASICS ..................................................................................... 220 Create a Report Using Report Design ................................................................................................. 225 35. MS ACCESS — FORMATTING REPORTS .......................................................................... 233 36. MS ACCESS — BUILT-IN-FUNCTIONS .............................................................................. 250 Functions ........................................................................................................................................... 250 Date & Time Functions ...................................................................................................................... 250 DateDiff() Function ............................................................................................................................ 256 Format() Function .............................................................................................................................. 258 IIf() Function ...................................................................................................................................... 262 v MS Access 37. MS ACCESS — MACROS ................................................................................................. 266 Creating a Macro ............................................................................................................................... 266 38. MS ACCESS — DATA IMPORT ......................................................................................... 275 Different Types of Data Access Can Import ........................................................................................ 275 39. MS ACCESS — DATA EXPORT ......................................................................................... 285 vi 1. MS Access – Overview MS Access Microsoft Access is a Database Management System (DBMS) from Microsoft that combines the relational Microsoft Jet Database Engine with a graphical user interface and software- development tools. It is a member of the Microsoft Office suite of applications, included in the professional and higher editions. Microsoft Access is just one part of Microsoft’s overall data management product strategy. It stores data in its own format based on the Access Jet Database Engine. Like relational databases, Microsoft Access also allows you to link related information easily. For example, customer and order data. However, Access 2013 also complements other database products because it has several powerful connectivity features. It can also import or link directly to data stored in other applications and databases. As its name implies, Access can work directly with data from other sources, including many popular PC database programs, with many SQL (Structured Query Language) databases on the desktop, on servers, on minicomputers, or on mainframes, and with data stored on Internet or intranet web servers. Access can also understand and use a wide variety of other data formats, including many other database file structures. You can export data to and import data from word processing files, spreadsheets, or database files directly. Access can work with most popular databases that support the Open Database Connectivity (ODBC) standard, including SQL Server, Oracle, and DB2. Software developers can use Microsoft Access to develop application software. Microsoft Access stores information which is called a database. To use MS Access, you will need to follow these four steps: Database Creation - Create your Microsoft Access database and specify what kind of data you will be storing. Data Input - After your database is created, the data of every business day can be entered into the Access database. Query - This is a fancy term to basically describe the process of retrieving information from the database. 1 MS Access Report (optional) - Information from the database is organized in a nice presentation that can be printed in an Access Report. Architecture Access calls anything that can have a name an object. Within an Access desktop database, the main objects are tables, queries, forms, reports, macros, data macros, and modules. If you have worked with other database systems on desktop computers, you might have seen the term database used to refer to only those files in which you store data. But, in Access, a desktop database (.accdb) also includes all the major objects related to the stored data, including objects you define to automate the use of your data. 2 2. MS Access – RDBMS MS Access Microsoft Access has the look and feel of other Microsoft Office products as far as its layout and navigational aspects are concerned, but MS Access is a database and, more specifically, a relational database. Before MS Access 2007, the file extension was *.mdb, but in MS Access 2007 the extension has been changed to *.accdb extension. Early versions of Access cannot read accdb extensions but MS Access 2007 and later versions can read and change earlier versions of Access. An Access desktop database (.accdb or .mdb) is a fully functional RDBMS. It provides all the data definition, data manipulation, and data control features that you need to manage large volumes of data. You can use an Access desktop database (.accdb or .mdb) either as a standalone RDBMS on a single workstation or in a shared client/server mode across a network. A desktop database can also act as the data source for data displayed on webpages on your company intranet. When you build an application with an Access desktop database, Access is the RDBMS. Data Definition Let us now understand what Data Definition is: In document or a spreadsheet, you generally have complete freedom to define the contents of the document or each cell in the spreadsheet. In a document, you can include paragraphs of text, a table, a chart, or multiple columns of data displayed with multiple fonts. In spreadsheet, you can have text data at the top to define a column header for printing or display, and you might have various numeric formats within the same column, depending on the function of the row. An RDBMS allows you to define the kind of data you have and how the data should be stored. You can also usually define rules that the RDBMS can use to ensure the integrity of your data. For example, a validation rule might ensure that the user can’t accidentally store alphabetic characters in a field that should contain a number. 3