1 MIS309 Database Systems Introduction to Microsoft Access.

133
1 MIS309 Database Systems Introduction to Microsoft Access

Transcript of 1 MIS309 Database Systems Introduction to Microsoft Access.

Page 1: 1 MIS309 Database Systems Introduction to Microsoft Access.

1

MIS309 Database Systems

Introduction toMicrosoft Access

Page 2: 1 MIS309 Database Systems Introduction to Microsoft Access.

2

Introduction

• In its simplest form, Access is a database application

• It uses a relational database management model, which means you can relate each piece of information to other pieces of information by joining them.

Page 3: 1 MIS309 Database Systems Introduction to Microsoft Access.

3

Create Tables

• By using wizard• By entering data• By design view

– specify field name, data type– set general attributes– set primary key

Page 4: 1 MIS309 Database Systems Introduction to Microsoft Access.

4

Establish Relationships

• Click the relationships button on the toolbar

• Tables are related by matching fields.

Page 5: 1 MIS309 Database Systems Introduction to Microsoft Access.

5

Types of Queries

• Select query• Update query• Append query• Delete query

Page 6: 1 MIS309 Database Systems Introduction to Microsoft Access.

6

Create Queries

• By using wizard– select table, fields– Not convenient to design complex

query

• By design view• By SQL view

– Input SQL sentence directly

Page 7: 1 MIS309 Database Systems Introduction to Microsoft Access.

7

Microsoft Access

Page 8: 1 MIS309 Database Systems Introduction to Microsoft Access.

8

Defining a New Data Base

Page 9: 1 MIS309 Database Systems Introduction to Microsoft Access.

9

Naming the Data Base

FileNameOK

Change Name/Directory

Page 10: 1 MIS309 Database Systems Introduction to Microsoft Access.

10

The New Data Base

Page 11: 1 MIS309 Database Systems Introduction to Microsoft Access.

11

Tables

Rowor Record

Fields

General Relational Data base Table

Id Name Age Address214 Jones 25 1 New St, Malvern

215

320

Key Field (Indexed)

Page 12: 1 MIS309 Database Systems Introduction to Microsoft Access.

12

Access Table

Page 13: 1 MIS309 Database Systems Introduction to Microsoft Access.

13

Define Fields in Table

Page 14: 1 MIS309 Database Systems Introduction to Microsoft Access.

14

Add The Name Field

Page 15: 1 MIS309 Database Systems Introduction to Microsoft Access.

15

Select Field Type

Page 16: 1 MIS309 Database Systems Introduction to Microsoft Access.

16

Set the Field’s Parameters

Page 17: 1 MIS309 Database Systems Introduction to Microsoft Access.

17

Name as Primary Key

Page 18: 1 MIS309 Database Systems Introduction to Microsoft Access.

18

Define the Image Field

SelectOLEObject

Page 19: 1 MIS309 Database Systems Introduction to Microsoft Access.

19

Image Parameters

Page 20: 1 MIS309 Database Systems Introduction to Microsoft Access.

20

Click to Save the Table

ClickYes

Page 21: 1 MIS309 Database Systems Introduction to Microsoft Access.

21

Name the Table

Page 22: 1 MIS309 Database Systems Introduction to Microsoft Access.

22

Table1 is now in the Database

Page 23: 1 MIS309 Database Systems Introduction to Microsoft Access.

23

Select Forms

Select NewForm

Page 24: 1 MIS309 Database Systems Introduction to Microsoft Access.

24

Associate Form with Table

Relate FormTo Table

Page 25: 1 MIS309 Database Systems Introduction to Microsoft Access.

25

Create Form for Table1

Select FormWizard

Page 26: 1 MIS309 Database Systems Introduction to Microsoft Access.

26

Select AutoForm

Page 27: 1 MIS309 Database Systems Introduction to Microsoft Access.

27

New Form -Run Mode

Page 28: 1 MIS309 Database Systems Introduction to Microsoft Access.

28

Close the Form

Page 29: 1 MIS309 Database Systems Introduction to Microsoft Access.

29

Save the Form

SelectYes

Page 30: 1 MIS309 Database Systems Introduction to Microsoft Access.

30

Name the Form

Page 31: 1 MIS309 Database Systems Introduction to Microsoft Access.

31

Form is part of the Database

Form inDatabase

Page 32: 1 MIS309 Database Systems Introduction to Microsoft Access.

32

Modify the Form

Page 33: 1 MIS309 Database Systems Introduction to Microsoft Access.

33

Delete the Current Title

ClickThe TitleandPress Delete

Page 34: 1 MIS309 Database Systems Introduction to Microsoft Access.

34

Select A in ToolBox for Title

Page 35: 1 MIS309 Database Systems Introduction to Microsoft Access.

35

Properties

Page 36: 1 MIS309 Database Systems Introduction to Microsoft Access.

36

Save the Change

Page 37: 1 MIS309 Database Systems Introduction to Microsoft Access.

37

Run The Form

Click OpenorDouble Click The Form

Page 38: 1 MIS309 Database Systems Introduction to Microsoft Access.

38

Add an Image Record

Page 39: 1 MIS309 Database Systems Introduction to Microsoft Access.

39

Type in the Name

Page 40: 1 MIS309 Database Systems Introduction to Microsoft Access.

40

Select ClipArt File

Page 41: 1 MIS309 Database Systems Introduction to Microsoft Access.

41

Copy Butterfly to Clipboard

Page 42: 1 MIS309 Database Systems Introduction to Microsoft Access.

42

Paste Butterfly to Image

Page 43: 1 MIS309 Database Systems Introduction to Microsoft Access.

43

The Butterfly goes to Image

Page 44: 1 MIS309 Database Systems Introduction to Microsoft Access.

44

Enter Next Record

Page 45: 1 MIS309 Database Systems Introduction to Microsoft Access.

45

Insert Object

RightMouseClick

Page 46: 1 MIS309 Database Systems Introduction to Microsoft Access.

46

Select Object Type

Page 47: 1 MIS309 Database Systems Introduction to Microsoft Access.

47

Select Graph

Page 48: 1 MIS309 Database Systems Introduction to Microsoft Access.

48

Graph

Page 49: 1 MIS309 Database Systems Introduction to Microsoft Access.

49

Clip Art

Page 50: 1 MIS309 Database Systems Introduction to Microsoft Access.

50

Cartoon

Page 51: 1 MIS309 Database Systems Introduction to Microsoft Access.

51

Add a “Next” Button

Page 52: 1 MIS309 Database Systems Introduction to Microsoft Access.

52

Name the Button

Page 53: 1 MIS309 Database Systems Introduction to Microsoft Access.

53

The Button Event

Page 54: 1 MIS309 Database Systems Introduction to Microsoft Access.

54

Exit Button

Page 55: 1 MIS309 Database Systems Introduction to Microsoft Access.

55

Name the “Exit” Button

Page 56: 1 MIS309 Database Systems Introduction to Microsoft Access.

56

The Exit Button

Page 57: 1 MIS309 Database Systems Introduction to Microsoft Access.

57

Event Coding

Sub Exit_Click ()On Error GoTo Err_Exit_Click

DoCmd Close

Exit_Exit_Click: Exit Sub

Err_Exit_Click: MsgBox Error$ Resume Exit_Exit_Click End Sub

Basic Subroutinedefined for Event

Event Operation

Exit the Subroutine

Error processing

Page 58: 1 MIS309 Database Systems Introduction to Microsoft Access.

58

Access database wizards, pages, and projects

• Access' wizards are existing database structures that only need data input.

Page 59: 1 MIS309 Database Systems Introduction to Microsoft Access.

59

Database Window

• The Database Window organizes all of the objects in the database.

Page 60: 1 MIS309 Database Systems Introduction to Microsoft Access.

60

Design View

• Design View customizes the fields in the database so that data can be entered.

Page 61: 1 MIS309 Database Systems Introduction to Microsoft Access.

61

Datasheet View The datasheet allows you to enter data into the

database

Page 62: 1 MIS309 Database Systems Introduction to Microsoft Access.

62

Create a Table in Design View

• Design View will allow you to define the fields in the table before adding any data to the datasheet.

Page 63: 1 MIS309 Database Systems Introduction to Microsoft Access.

63

Adding Records

• Add new records to the table in datasheet view by typing in the record beside the asterisk (*) that marks the new record.

Page 64: 1 MIS309 Database Systems Introduction to Microsoft Access.

64

Hiding Columns

• Columns can also be hidden from view on the datasheet although they will not be deleted from the database.

Page 65: 1 MIS309 Database Systems Introduction to Microsoft Access.

65

Finding Data in a Table• Data in a datasheet can be quickly located by

using the Find command.

Page 66: 1 MIS309 Database Systems Introduction to Microsoft Access.

66

Table Relationships • Relationships can be established to link fields of

tables together.

Page 67: 1 MIS309 Database Systems Introduction to Microsoft Access.

67

Enforce Referential Integrity

Page 68: 1 MIS309 Database Systems Introduction to Microsoft Access.

68

• A line now connects the two fields in the Relationships window.

Enforce Referential Integrity

Page 69: 1 MIS309 Database Systems Introduction to Microsoft Access.

69

Create a Query in Design View

Page 70: 1 MIS309 Database Systems Introduction to Microsoft Access.

70

Create a Query in Design View

Page 71: 1 MIS309 Database Systems Introduction to Microsoft Access.

71

Create a Query in Design View

Page 72: 1 MIS309 Database Systems Introduction to Microsoft Access.

72

Create query by using wizard

Page 73: 1 MIS309 Database Systems Introduction to Microsoft Access.

73

Create query by using wizard

Page 74: 1 MIS309 Database Systems Introduction to Microsoft Access.

74

Find Duplicates Query

Page 75: 1 MIS309 Database Systems Introduction to Microsoft Access.

75

New Query Example

Click New

Page 76: 1 MIS309 Database Systems Introduction to Microsoft Access.

76

Select Design View for New Query

Design View

Page 77: 1 MIS309 Database Systems Introduction to Microsoft Access.

77

Select the Members Table for the Query

Add Membersthen Close

Page 78: 1 MIS309 Database Systems Introduction to Microsoft Access.

78

Select Fields for Query

Select Field

Page 79: 1 MIS309 Database Systems Introduction to Microsoft Access.

79

Selection Criteria

Criteria

Page 80: 1 MIS309 Database Systems Introduction to Microsoft Access.

80

View the Selected Data

View Selected data

Page 81: 1 MIS309 Database Systems Introduction to Microsoft Access.

81

The Selected Data

Page 82: 1 MIS309 Database Systems Introduction to Microsoft Access.

82

View Query SQL

SQL

Page 83: 1 MIS309 Database Systems Introduction to Microsoft Access.

83

The Query SQL Code

Page 84: 1 MIS309 Database Systems Introduction to Microsoft Access.

84

Save the Query

Save

Page 85: 1 MIS309 Database Systems Introduction to Microsoft Access.

85

The Saved Query

Page 86: 1 MIS309 Database Systems Introduction to Microsoft Access.

86

View the Query Data

Page 87: 1 MIS309 Database Systems Introduction to Microsoft Access.

87

Create Form by Using Wizard

Page 88: 1 MIS309 Database Systems Introduction to Microsoft Access.

88

Create Form by Using Wizard

Page 89: 1 MIS309 Database Systems Introduction to Microsoft Access.

89

Create Form by Using Wizard

Page 90: 1 MIS309 Database Systems Introduction to Microsoft Access.

90

Create Form in Design View

Page 91: 1 MIS309 Database Systems Introduction to Microsoft Access.

91

Create Form in Design View

Page 92: 1 MIS309 Database Systems Introduction to Microsoft Access.

92

Sample Form

Page 93: 1 MIS309 Database Systems Introduction to Microsoft Access.

93

Adding Records Using A Form

Page 94: 1 MIS309 Database Systems Introduction to Microsoft Access.

94

Form Controls

Page 95: 1 MIS309 Database Systems Introduction to Microsoft Access.

95

Reports

Page 96: 1 MIS309 Database Systems Introduction to Microsoft Access.

96

Reports

Page 97: 1 MIS309 Database Systems Introduction to Microsoft Access.

97

An Access Report with All Sections Shown

Page 98: 1 MIS309 Database Systems Introduction to Microsoft Access.

98

Exporting Access Query to Excel Workbook File

Page 99: 1 MIS309 Database Systems Introduction to Microsoft Access.

99

Reposition and Resize Controls in Subreport

Page 100: 1 MIS309 Database Systems Introduction to Microsoft Access.

100

Query Data Exported to an Excel Worksheet

Page 101: 1 MIS309 Database Systems Introduction to Microsoft Access.

101

Import Data from Other Applications as an Access Table

• You can import data from a variety of other applications, including Excel lists, as an Access table.

• If you import data from an Excel list, be sure that the range of the list is named before attempting to import the data in the list.

Page 102: 1 MIS309 Database Systems Introduction to Microsoft Access.

102

Import Spreadsheet Wizard Dialog Box

Page 103: 1 MIS309 Database Systems Introduction to Microsoft Access.

103

First Row Contains Column Headings

Page 104: 1 MIS309 Database Systems Introduction to Microsoft Access.

104

“Choose primary key” Option

Page 105: 1 MIS309 Database Systems Introduction to Microsoft Access.

105

Imported Trial Balance Table in Datasheet View

Page 106: 1 MIS309 Database Systems Introduction to Microsoft Access.

106

Macros in Microsoft Access

• Use to Open or Close Forms and Reports

• Print Reports, or send to other Applications

• Build Menus • Execute a command from a Menu

• Display Messages or Sound Beeps

• Start Other Applications

Page 107: 1 MIS309 Database Systems Introduction to Microsoft Access.

107

A Simple Button Menu Form

Open Form A

Open Form B

Exit

Page 108: 1 MIS309 Database Systems Introduction to Microsoft Access.

108

Button for Form A

Page 109: 1 MIS309 Database Systems Introduction to Microsoft Access.

109

Name the Button and Finish

Page 110: 1 MIS309 Database Systems Introduction to Microsoft Access.

110

The Button to Open Form A

Page 111: 1 MIS309 Database Systems Introduction to Microsoft Access.

111

Button Wizard gives VB Event Procedure

Page 112: 1 MIS309 Database Systems Introduction to Microsoft Access.

112

Event Procedure for the OpenA Button

Page 113: 1 MIS309 Database Systems Introduction to Microsoft Access.

113

Cancel Wizard to Define a OpenB

Wizard Off

AdjustSize

OpenB

Open Form B

Page 114: 1 MIS309 Database Systems Introduction to Microsoft Access.

114

Define a Macro for OpenB OnClick Event

ClickDots

SelectMacro

Click

Page 115: 1 MIS309 Database Systems Introduction to Microsoft Access.

115

Name the Macro

ClickOpen Form B

Page 116: 1 MIS309 Database Systems Introduction to Microsoft Access.

116

Select OpenForm

Click

Page 117: 1 MIS309 Database Systems Introduction to Microsoft Access.

117

Macro: Open Form B

FormB

Click

Page 118: 1 MIS309 Database Systems Introduction to Microsoft Access.

118

System Check

Click

Page 119: 1 MIS309 Database Systems Introduction to Microsoft Access.

119

Add the Exit Button

Click

WizardOn

Click

Page 120: 1 MIS309 Database Systems Introduction to Microsoft Access.

120

The Exit Button

Page 121: 1 MIS309 Database Systems Introduction to Microsoft Access.

121

Exit.OnClick Event Procedure

Page 122: 1 MIS309 Database Systems Introduction to Microsoft Access.

122

Run the Simple Menu

Click

Page 123: 1 MIS309 Database Systems Introduction to Microsoft Access.

123

Event Procedure - Form A

Page 124: 1 MIS309 Database Systems Introduction to Microsoft Access.

124

Event Macro - Form B

Page 125: 1 MIS309 Database Systems Introduction to Microsoft Access.

125

Form with Local Event Procedures

Page 126: 1 MIS309 Database Systems Introduction to Microsoft Access.

126

Local Event Procedures or Functions

Click

Page 127: 1 MIS309 Database Systems Introduction to Microsoft Access.

127

Local VBA Code

Page 128: 1 MIS309 Database Systems Introduction to Microsoft Access.

128

Module Area

Page 129: 1 MIS309 Database Systems Introduction to Microsoft Access.

129

Global Values and Procedures

Page 130: 1 MIS309 Database Systems Introduction to Microsoft Access.

130

How Big with Access

There are file size limitations with MS Access.

Tables 95Queries 29Forms 511Reports 185Code 500 (200,000 statements)

Table Space 800MbCode Space 60Mb

Page 131: 1 MIS309 Database Systems Introduction to Microsoft Access.

131

Garbage Collection

Regular Compacting is required to keep size down.

(Tools/Utilities/Compact)

Page 132: 1 MIS309 Database Systems Introduction to Microsoft Access.

132

MS Access - Offers

TablesDatabase Table Definition/Entry

Queries SQL Queries against Tables

Forms Forms to be displayed

Reports Reports to be Printed

Macros Macro Commands

Modules Visual Basic Code

Page 133: 1 MIS309 Database Systems Introduction to Microsoft Access.

133

End of Lecture

• MS Access is include with some versions of MS Office. It can be learned by experimentation.

• MS Access is not a full featured database like Oracle but it comes very close and is a good alternative for the PC desktop environment.