sir area 16 computers and technology activity

45
Introduction to Microsoft Access SIR DAN WELLER SIR BRANCH 8 NOVEMBER 19, 2020 SIR Area 16 Computers and Technology Activity

Upload: others

Post on 04-Apr-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Introduction to Microsoft AccessSIR DAN WELLER

SIR BRANCH 8

NOVEMBER 19, 2020

SIR Area 16Computers and Technology Activity

11/19/2020Intro to MS Access

Agenda

• Audience

• What if …

• What is Access and Where Does it Fit in the Office Lineup

• Access Environment

• Functionality

• Database / Tables

• Query Tool

• Form and Reports

• Macros and VBA

• External Data

• Demos

• Best Practices

• Should You Use Access?

• Q & A

2

11/19/2020Intro to MS Access

Audience …

• The target audience for this presentation is members

who have never used Access.

• We are assuming that the attendees are familiar with

Excel or other spreadsheet apps.

• We will focus on what Access can do, not necessarily

how Access objects are developed.

• We will define new terms just before they are

introduced.

• If you are familiar with Access, you will probably

discover new ways to use Access.

3

11/19/2020Intro to MS Access

What if …

• You are a Big SIR and need to manage your membership, keep track of luncheon attendance, and want to track activity participation. Plus, you need to record a history of each members branch roles.

• Inventory most of the items in your home. Include name, when purchased, value, store, warranty info, serial numbers, locations in your house. Create a simple data entry screen and have queries that allow you to filter on any of the fields.

• You are running a small business from your home and you need to manage customers, orders, inventory, purchasing, suppliers, shipping and a few workers. Three workers need to use the system at the same time.

So, what MS Office tool(s) should you use for developing apps similar to the ones stated above?

4

11/19/2020Intro to MS Access

FunctionsQuality Data

Query Data

Forms and Reports

External Data

Documents,

Reports, Mail-

Merge

Up to the user No Yes Files

Spreadsheets,

Graphs, Pivot

Tables

Some user

developed

tricks

Sort of,

e.g. filter

& pivot tb

Simple reports

and formsFiles

Presentations Up to the user No No Files

Email Up to the user No No No

Newsletters,

PostersUp to the user No No No

Database with

graphic tools for

forms and reports

Intelligent DB

ensures some

quality

Full

function

Full function with

Wizards

Very strong

external data

import / export

and linking

What Office Apps Should We Use?

5

11/19/2020Intro to MS Access

What is Access?

Microsoft Access is a database management

system (DBMS) from Microsoft that combines the

relational Microsoft Database with a graphical

user interface and software development tools.

6

Per Wikipedia

Database

A database is an organized collection of structured data stored electronically in a computer system. The data can then be easily accessed, managed, modified, updated, controlled, and organized.

11/19/2020Intro to MS Access

Access Environment

7

The primary Access component is tables.

These tables look very much like Excel sheets in that they have rows, columns and cells. Each table has a unique name and each column has a name and attributes such as data type, size and optionality. Table rows do not have names or numbers.

The Access database is a modern data base and supports most of the functions offered in commercial Data Base Management Systems such as Oracle, DB2 or SQL Server.

Access supports multiple concurrent users.

Robust security is available.

Access is a Windows application. There is not a MAC version of Access.

11/19/2020Intro to MS Access

So, Let's Look Into Access

8

ACCESS Component Summary• Relational Database• Query Tool• Forms• Reports• Robust Macro Language• Powerful Visual Basic• User Apps with Record Level Locks• Easy Read and Update Access to External Data

We will spend most of our time with the first two components because they are the core things that a database does.

11/19/2020Intro to MS Access

Some More Definitions

9

Relational Database

A relational database is a type of database that stores and provides access to data points that are related to one another.

Primary KeyA primary key is one or more columns in a table where the value of the key uniquely identifies a table row.

Foreign KeyA foreign key is the presence of another table's primary key in a child table.

11/19/2020Intro to MS Access

Our Demo Database

10

Our demo database is a simple three-table app that has relationships, queries, forms and reports.

• WALK has an inventory of walks. The table has detailed info on the walk location, directions to a staging area, and what cafe we meet after the walk. Each walk may be used several times during a calendar year or not.

• WALK_CAFE is a list of coffee shops. Each row has the cafe name, location and phone.

• WALK_SCHEDULE has the list of weekly walks. It also names the leader for each walk.

11/19/2020Intro to MS Access

Tables – Demo Details

11

WALK Table Data

WALK Table DefinitionAccess supports many type of data, many of which you will probably never use.

11/19/2020Intro to MS Access

Tables Continued … Demo Details

12

WALK_CAFE

WALK_SCHEDULE

11/19/2020Intro to MS Access

Tables Continued … Relations

13

TablesDatabase

Relations

C

PP

C

11/19/2020Intro to MS Access

Relation Comments

14

• By default, Access does not create relations – you have to do this via the "Database Tools / Relations" tool in Access

• Relations are enforced connections between tables

➢ You can't change a parent key value if any child links exist

➢ Child values must match a corresponding parent value

• Relations are part of the table definitions and can't be overridden by queries or programming

• Formal relations are not required. Use them for critical tables

➢ But, you can ensure data quality by using drop down lists and other techniques (more about this later)

11/19/2020Intro to MS Access

Tables and Relations Demo

15

11/19/2020Intro to MS Access

Queries

16

Queries can be very simple or very complex.

There are two ways to create queries:

• Write the code to do your query using Structured Query Language (SQL). This is for the data nerds.

• Use the Access Query By Example (QBE) graphic tool to make your query. We will use this tool for this presentation.

Query

A database query is a request for data from a database. Usually the request is to retrieve data; however, data can also be manipulated using queries. The data can come from one or more tables, or even other queries.

Query Line

A line that connects fields between two tables and shows how the data is related.

11/19/2020Intro to MS Access

Query - Intro

17

1

2

Drag the table(s) to the top of the form

Drag the field names to the "Field" row.

Enter the criteria.

3

4

That's lame-where is the Walk info?

What walks did Dan lead this year?

11/19/2020Intro to MS Access

Queries – Simple Join

18

1

2Click the WALK (WALK_NBR) field and drag to the WALK_EVENT (WALK_NBR) field. This creates the join line.

Drag the WALK table to here.

4

What walks did Dan lead this year?

Enter Criteria

5

3Drag the preferred fields to here.

11/19/2020Intro to MS Access

Join - Notes

19

1. The join links a field in one table to a field in another table. The names don't need to be the same.

2. The joined fields do not have to be primary key fields. Any two table names can be joined.

3. If the joined fields have the same value, the requested fields are in the result, else both rows are ignored.

4. The join looks like a relation line, but it is only a one-time link.

5. More that one join can be done. For example, you might want to link First Name and Last Name in two tables. Then both links need to match for the rows to be displayed.

11/19/2020Intro to MS Access

Query – Aggregate Queries

20

Request: How many times has each cafe been used?

1

3

Aggregate Functions

2

11/19/2020Intro to MS Access

Query Thoughts

21

1. Queries are very powerful and can get quite complicated. Take it easy and start with a small query that works and then add more conditions and tables to sneak up on the solution.

2. Queries can update fields, delete rows, append rows and create new tables. Be very careful because there is no "undo" on these types of transactions.

3. You can use a query to be input into another query. For example, our count of cafes used could be input to another query which summed each cafe count to get the total number of cafe visits.

4. Queries are often used in forms and reports to deliver specific data for dropdown lists and create a data source for the form or report.

11/19/2020Intro to MS Access 22

Queries Demo

11/19/2020Intro to MS Access

Access Forms

23

Form

A form is a database object that you can use to enter, edit, or display data from a table or a query. You can use forms to control access to data, such as which fields of data are displayed.

11/19/2020Intro to MS Access

Let's Make a Simple Form

24

11/19/2020Intro to MS Access

Our First Form !

25

Generated By the Form Wizard After Cosmetic Enhancements

11/19/2020Intro to MS Access

Form Comments

26

1. Forms are needed for developing end-user apps.

2. Forms can get very complicated and difficult to develop, especially with forms that have several embedded forms.

3. Forms play a big role in ensuring data quality by using event triggers that check the contents of field updates and drop-down lists that only allow certain values.

4. Macros and Visual Basic are often used to validate data quality.

11/19/2020Intro to MS Access 27

Forms Demo

11/19/2020Intro to MS Access

Access Report Tool

28

• The Access Report tool is both easy for new users and very sophisticated for professional developers.

• Hierarchical reports are supported with subtotals and final totals.

• Custom fields and calculations and well as charts can be included in the report.

• You can have sub-reports embedded in the main body of the report.

• Reports are read-only (in case you wondered).

Report

A report consists of information that is pulled

from tables or queries, as well as information that

is stored with the report design, such as labels, headings, and graphics.

11/19/2020Intro to MS Access

Let's Make a Simple Report

29

11/19/2020Intro to MS Access

Report Making - 2

30

11/19/2020Intro to MS Access

The Generated Report

31

11/19/2020Intro to MS Access

The Enhanced Report

34

11/19/2020Intro to MS Access

Another Report

35

11/19/2020Intro to MS Access 36

Reports Demo

11/19/2020Intro to MS Access

Macros

37

• If you are familiar with Excel or Word macros, you will be surprised that Access macros are totally different (Access is easier to use).

• Macros can get extremely complex and large. It is recommended that you start with simple one-function macros and add functionality as you get comfortable with this tool.

• The good news is that macros require no programming. The bad news is that macros require no programming.

Macro Demo

Macro

A macro is a stored series of commands that carry out an action or a string of actions. This feature can be used to add functionality or automate simple tasks, such as performing an action when the user clicks a button.

11/19/2020Intro to MS Access

VBA – Visual Basic for Applications

38

• VBA is available for all Microsoft Office applications. VBA is a programming language, so don't try using this unless you have some programming experience.

• VBA is used to provide functions and logic that is not in the normal Access design.

11/19/2020Intro to MS Access

External Data

39

Access is called "Access" because of the numerous data sources that the program can "Access".

IMPORT EXPORT

11/19/2020Intro to MS Access

Three Types of Import

40

1. Local Import: External data is copied to Access as local tables. Changes to the local data are not reflected in the source data and vv.

2. Linked Data: A link is developed between the Access program and an external data source.

3. Access Components: One Access program can copy tables, queries, forms, reports, macros and modules (VBA) from another Access program.

11/19/2020Intro to MS Access

Export Example

41

WALK_CAFETable

Access

Word

Excel

PDF

TXT

XML

HTML

ODBC(MySQL)

11/19/2020Intro to MS Access

Beautiful Linked DB Tables

42

1. As you saw earlier, Access can "link" to external data, including non-database data.

2. Non-database data is "read only" in Access, but Access will see changes made to the source data.

3. Links to database tables are updatable and multiple people can link to the same external table at the same time and work on different rows.

4. It is highly recommended that you always build a "data only" Access database that only has tables. These tables will be linked-to from other Access programs that have queries, forms and reports.

This design creates a single storage of "data of record" and eliminates out-of-sync copies of data.

11/19/2020Intro to MS Access

Two-Tiered Systems

43

MySQLDatabase TablesAccess

Tables

Windows Server

Core Attendance Membership

11/19/2020Intro to MS Access

How to Start With Access – It Depends

44

• If you never used a spreadsheet program• Find a nerd to help you. Don't do this by yourself

• If you are proficient with Excel, but not DB• Get and follow a "Dummies" Access book • Start with simple tables and queries• Slowly add complexity

• If you are familiar with database design and usage• Start with simple tables and queries• Slowly add complexity• Use Access templates to start your program if

there is an appropriate template• If you have object programming and database

experience• Go for it. Use reference books or Google to get

help on certain tasks• Get a good Access development book and use it• Follow Access Best Practices

11/19/2020Intro to MS Access

Best Practices

45

1. Normalize your table design if your tables are "data of record".

2. Create an Access database that only has tables that are linked to by child Access programs. This is required for multiple concurrent users, and is a good idea if only one user.

3. Name all of your components with clear names.

4. Use object type prefixes on all components. Examples: tblPERSON, qryActiveMembers, frmMainMenu, rptMonthEndStats, macInitialize, fnCalcAge

5. Use "camel" format or underscore for your component names. Examples: ACTIVITY_ROLE or ActivityRole. Do NOT use spaces between words.

6. Use change control on your Access programs, especially if changing a production program. Do frequent backups and use versioning and change logs to facilitate recovery.

11/19/2020Intro to MS Access

Reference Materials

46

Title Location Notes

Access 2016 Beginner Tutorial

https://www.youtube.com/watch?v=1XTXv1V3-ag

Online 3.5 hour Tutorial

Access in Easy Steps Amazon Mike McGrath

Access Data Normalization

https://www.youtube.com/results?search_query=access+normalize+data

A nice 7 minute look at simple data normalization

11/19/2020Intro to MS Access

Questions and Comments

47