Вы находитесь на странице: 1из 24

MS Access

Introduction

MS Access
Relational data model
Data is stored in tables incorporated into database files with extension mdb or accdb

Standard Windows interface Standard Help system Part of MS Office suite


Marina G. Erechtchoukova 2

Access Database Objects


Tables contain rows called records and columns called fields. Queries are requests for specific information from a database. Queries are virtual tables built on a given SQL statement

Marina G. Erechtchoukova

Access Database Objects

(cont. )

Forms are parts of user interface. Forms are used to enter, edit or browse data from a database
Reports present requested information and allow to create hard copies.

Marina G. Erechtchoukova

Data Types
Text Memo Numbers
Byte Integer Long integer Single Double

Currency AutoNumber Yes/No


Yes/no True/False 1/0

Date/time

OLE Objects Hyperlink Lookup Wizard


Marina G. Erechtchoukova 5

Create a Database in MS Access 2007 and up


Click on the round Office button Choose New from the drop-down menu In Create Blank Database window specify the database name Click Create

Marina G. Erechtchoukova

Create Table
Using Wizard Design View
Specify field names Data types Properties Determine a primary key Save the table

Marina G. Erechtchoukova

Access Tables
Design view
Table structure is created and may be edited

Datasheet view
Display table content in spreadsheet-like grid, Used for entering, editing or deleting data from tables

Marina G. Erechtchoukova

Referential Integrity Constraints


Referential Integrity Can be established or removed in Relationship window
In MS Access 1995-2003 open menu Tools and choose Relationships from the drop-down menu

In MS Access 2007 and up choose Database Tools tab and then Relationships Use drag-and-drop features and select Enforce Referential Integrity option Tip specify referential integrity constraints before data is entered
Marina G. Erechtchoukova 9

Queries
Specify the source of data If multiple tables are used, specify relationships between tables Select desirable fields from the table(s) and options related to the fields Specify a criterion

Marina G. Erechtchoukova

10

Query Criteria
To be selected a record must satisfy a criterion Expressions may contain the following operators:
Math Operators Relational operators Boolean Operators String Operators Miscellaneous Operators
Marina G. Erechtchoukova 11

Math Operators
+
*

Addition
Subtraction Multiplication

/
\ ^ Mod

Division
Integer Division Exponentiation Modulo (remainder) division

Marina G. Erechtchoukova

12

Relational Operators
= <> < > <= >= Equal Not equal Less than Greater than Less than or equal to Greater than or equal to

Marina G. Erechtchoukova

13

Boolean Operator
And
Or

Logical And
Logical Or

Both operands are true


Either one of the operands or both of them are true Only one of the operands (not both of them) are true Operand is not true
14

Xor

Excusive Or

Not

Negation

Marina G. Erechtchoukova

String and Miscellaneous Operators


&
Like

Concatenation
Similar to

Between Between 2 values inclusive and In (list) One from the list
Is Null True if the field is empty

Marina G. Erechtchoukova

15

Access Forms
Create using Form Wizard Create using Form Design view
Specify source of data will be presented by the form
Table Query

Specify fields related to the form Add labels, titles, graphics and so on
Marina G. Erechtchoukova 16

Form Design view


Form Header a place for titles, graphics, additional information Form Details section the fields used to create a form and control elements related to the fields Form footer a place for any items which will appear at the bottom of the form
Marina G. Erechtchoukova 17

Form Controls
Must be bound with fields from the source table or query Contain data from correspondent fields, labels or other controls (like command button) or another form called subform

Marina G. Erechtchoukova

18

Viewing Forms
Open database Click Forms tab to display all available forms in the database Select the form Select Open To view data use Form Navigation Tools. To prevent data Editing, use Locked Property for the Text Boxes
Marina G. Erechtchoukova 19

Creating Subforms
Represent 1:N relationships To add a subform to a form
Create a form that will be a subform Click on Subform/Subreport button and then click on a form where the subform should appear Specify the source for the subform Specify the fields to link the form and subform
Marina G. Erechtchoukova 20

Reports
Reports present table contents or query results in an easily assimilated format Reports have Design view and Print Preview Report Design View is similar to the Form Design view

Marina G. Erechtchoukova

21

Report Design View


Page Header contains data and graphics appearing at the top of each page Report Header contains the data and graphics appearing at the top of the first report page Detailed section contains data from tables or queries Page Footer contains the data and graphics appearing at the bottom of every page Report Footer contains the data and graphics appearing at the bottom of the last report page
Marina G. Erechtchoukova 22

Report Types
Columnar reports a single record on a page Tabular reports datasheets: fields from the tables are presented as columns Justified reports combine two previous types of the reports
Marina G. Erechtchoukova 23

Creating Reports
With a Wizard Design view:
Specify source for the report Select Fields from the Fields List Add labels Add format Switch the view to see the result.

Marina G. Erechtchoukova

24

Вам также может понравиться