Vous êtes sur la page 1sur 43

1) Define:

Database- A database is a tool for collecting and organizing information. Databases can store information
about people, products, orders, or anything else. Many databases start as a list in a word-processing
program or spreadsheet. As the list grows bigger, redundancies and inconsistencies begin to appear in the
data. The data becomes hard to understand in list form, and there are limited ways of searching or pulling
subsets of data out for review. Once these problems start to appear, it's a good idea to transfer the data to a
database created by a database management system (DBMS), such as Access 2010

A computerized database is a container of objects. One database can contain more than one table. For
example, an inventory tracking system that uses three tables is not three databases, but one database that
contains three tables. Unless it has been specifically designed to use data or code from another source, an
Access database stores its tables in a single file, along with other objects, such as forms, reports, macros,
and modules. Databases created in the Access 2007 format (which is also used by Access 2010) have the
file extension .accdb, and databases created in earlier Access formats have the file extension .mdb. You can
use Access 2007 or Access 2010 to create files in earlier file formats (for example, Access 2000 and Access
2002-2003).

Using Access, you can:

 Add new data to a database, such as a new item in an inventory

 Edit existing data in the database, such as changing the current location of an item

 Delete information, perhaps if an item is sold or discarded

 Organize and view the data in different ways

 Share the data with others via reports, e-mail messages, an intranet , or the Internet

The following sections are short descriptions of the parts of a typical Access database:

o Tables
o Forms
o Reports
o Queries
o Macros
o Modules

Foreign key-A foreign key is used to link a table to another table. It is best explained by an
example.

Lets say you want to build a database of students-coursework. Each student can take multiple
courses. If you use just one table, you will create a lot of redundancies i.e. you will be repeating all
of student data for each course the student takes. And if in future, the student's details (like phone
number) changes, you will have to update each occurrence. Such a database design is called
"unnormalized". You should use normalized design. 
Under normalized design, 2 tables: one table for students, in which you will assign a unique
number to each student, lets call it ID. In the second table, called "course" table, you will list only
the ID of each student and the course detail. The two tables are linked by ID. ID in student table
will be called "primary key" and in the course table it is called "foreign key".
Note that there is scope for further normalization. The course table can be further broken to reduce
redundancy: you will list all the available courses in "course" table, that contains a unique course
number for each course; then create a third table "student_course" that contains only 2 fields:
student ID and course number. Thus, there are 2 foreign keys.

How to set it:


Go to tools-->relationships
this will list the tables. click on the primary key in the parent table and drag it to the foreign key in
the child table. Access will automatically make it as a foreign key and may even suggest the kind of
relationship (one to many etc..)

foreign keys are used to connect two tables together by a single field (employee ID, patient ID,
customer ID)...

without that, u can't manage the same person's records on two different tables. 

to set foreign keys, you must put the same ID on both tables, and then go into relationship view.
here, you drag the ID from one table to the other and maintain a recursive relationship (one-to-
many)

 Foreign key    A table can also have one or more foreign keys. A foreign key contains values

that correspond to values in the primary key of another table. For example, you might have an

Orders table in which each order has a customer ID number that corresponds to a record in a

Customers table. The customer ID field is a foreign key of the Orders table.

Parameterized query-A useful feature of the query is that it can be saved and used again and
again, whenever we want to ask the same question. The result we see (the dynaset) always reflects

the most up-to-date information in the database because what you save is the question, not the

answer. You just ask the question again by running the query.

Sometimes we want to ask a question time and time again, but the details (the query's criteria)

may vary. It would be handy to have a way to run a query and make changes to its criteria without

having to design a completely new one from scratch. Access has a tool to solve that problem,

the Parameter Query.

In fact, the parameter query can be any sort of query. You just employ the methods described here

to design the criteria.


When you run a parameter query Access presents you with a dialog box prompting you for the

parameter value, which it enters into the appropriate criteria cell. You can have as many

parameters as you like in a single query.

Form- A form is a database object that you can use to create a user interface for a database application. A
"bound" form is one that is directly connected to a data source such as a table or query, and can be used to
enter, edit, or display data from that data source. Alternatively, you can create an "unbound" form that does
not link directly to a data source, but which still contains command buttons, labels, or other controls that you
need to operate your application.

This article focuses primarily on bound forms. You can use bound forms to control access to data, such as
which fields or rows of data are displayed. For example, certain users might need to see only several fields
in a table with many fields. Providing those users with a form that contains only those fields makes it easier
for them to use the database. You can also add command buttons and other features to a form to automate
frequently performed actions.

Think of bound forms as windows through which people see and reach your database. An effective form
speeds the use of your database, because people don't have to search for what they need. A visually
attractive form makes working with the database more pleasant and more efficient, and it can also help
prevent incorrect data from being entered.

 NOTE    This article assumes you have already created a table (or a query based on one or more tables),
and that you want to build a form to view or manipulate the data.

Reports- When you use a database, you typically use reports to view, format, and summarize data. For
instance, you might create a list-type report to display phone numbers for all your contacts, or a summary
report to total up the sales for your company across different regions and time periods.

This article provides an overview of reports in Microsoft Access 2010, and introduces new or changed report
features. This article also explains how to create a report, how to sort, group, and summarize data, and how
to preview and print a report.

You’ll find it’s much easier to create meaningful reports if your database has a well-designed table structure
and relationships.

A report is a database object that you use to display and summarize data. Reports provide a way to
distribute or archive snapshots of your data, either by being printed out, converted to PDF or XPS files, or
exported to other file formats.
Reports can provide details about individual records, summaries across many records, or both. You can also
use Access reports to create labels for mailings or other purposes.

It is possible to create “unbound” reports that do not display data, but for the purposes of this article, we’ll
assume that a report is bound to a data source such as a table or query.

CLIENT REPORTS VS. WEB REPORTS

Access 2010 provides a new feature that allows you to create a “Web database” by publishing an Access
database to a SharePoint server that is running Access Services. When you create a Web database, Access
reports are rendered in the browser using SQL Server Reporting Services. This conversion places some
limitations on the features you can use in reports that you want to render in the browser. However, if you are
not concerned about the report rendering in the browser, you can use the full set of features that the Access
report designer provides.

PARTS OF A REPORT

In Access, the design of a report is divided into sections. In a client database, you can view your report in
Design view to see its sections. In Layout view, the sections are not as obvious, but they are still there, and
can be selected by using the drop-down list in the Selection group on the Format tab. To create useful
reports, you need to understand how each section works. For example, the section in which you choose to
place a calculated control determines how Access calculates the results. The following list is a summary of
the section types and their uses:

 Report Header   This section is printed just once, at the beginning of the report. Use the report

header for information that might normally appear on a cover page, such as a logo, a title, or a date. When
you place a calculated control that uses the Sum aggregate function in the report header, the sum calculated

is for the entire report. The report header is printed before the page header.

 Page Header   This section is printed at the top of every page. For example, use a page header to

repeat the report title on every page.

 Group Header   This section is printed at the beginning of each new group of records. Use the

group header to print the group name. For example, in a report that is grouped by product, use the group

header to print the product name. When you place a calculated control that uses the Sum aggregate

function in the group header, the sum is for the current group. You can have multiple group header sections

on a report, depending on how many grouping levels you have added. For more information about creating

group headers and footers, see the section Add grouping, sorting, or totals.

 Detail   This section is printed once for every row in the record source. This is where you place the

controls that make up the main body of the report.

 Group Footer   This section is printed at the end of each group of records. Use a group footer to

print summary information for a group. You can have multiple group footer sections on a report, depending

on how many grouping levels you have added.

 Page Footer   This section is printed at the end of every page. Use a page footer to print page

numbers or per-page information.

 Report Footer   This section is printed just once, at the end of the report. Use the report footer to

print report totals or other summary information for the entire report.

 NOTE     In Design view, the report footer appears below the page footer. However, in all other views
(Layout view, for example, or when the report is printed or previewed), the report footer appears above the
page footer, just after the last group footer or detail line on the final page.

2g) Define the term attributes in database-

Tables and fields have properties that you can set to control their characteristics or behavior. In an Access
database, table properties are attributes of a table that affect the appearance or behavior of the table as a
whole. Table properties are set in the table's property sheet, in Design view. For example, you can set a
table's Default View property to specify how the table is displayed by default.

A field property applies to a particular field in a table and defines one of the field's characteristics or an
aspect of the field's behavior. You can set some field properties in Datasheet view (Datasheet view: A view
that displays data from a table, form, query, view, or stored procedure in a row-and-column format. In
Datasheet view, you can edit fields, add and delete data, and search for data.). You can also set any field
property in Design view by using the Field Properties pane.

3)How is access different from excel?

Microsoft produces two different products---Access and Excel---that many people use
interchangeably. However, each has its own purpose and one may be better for your needs
than the other. While both cost the same, they are vastly different. Knowing those differences
can help you pick the right one for your needs.

1. Purpose
o The most important difference between Microsoft Access and Microsoft Excel
is the purpose. Access is a relational database management system, while Excel is a
spreadsheet. Access manages large amounts of data, and Excel does math.

Availability
o Both Access and Excel may be purchased separately. If you want to buy an
Office package from Microsoft, Excel is available in the Home, Student and Professional
packages, while Access is included only in Professional.

Relational Data
o If you need to create relationships between your data, Access is the only
choice. Because it uses only flat files, Excel has limited functionality and cannot make the
connections that Access can.
Ease of Use
o Excel is more user-friendly and intuitive than Access, with a GUI that
resembles Word, a commonly used program.

Size
o Excel can only handle up to 15,000 records. Access is meant to handle
thousands of records, all related through multiple tables.

Querying
o Access is meant to create calculated queries, making connections based
through a "wizard" or through user programming. Excel does not have the ability to do so,
although it can create charts, graphs and pivot tables.

Calculations
o Excel is meant to handle numerical data and run equations. Access is
capable of doing so, but that is not meant to be its main function.

(refer from notes as well)

4) Define key attribute? How primary key is different from super key or candidate key?
Because you store data about different subjects in separate tables, you need some way to tie the data
together so that you can easily combine related data from those separate tables. To connect the data stored
in different tables, you create relationships. A relationship is a logical connection between two tables that
specifies fields that the tables have in common.

Keys

Fields that are part of a table relationship are called keys. A key usually consists of one field, but may
consist of more than one field. There are two kinds of keys:

 Primary key    A table can have only one primary key. A primary key consists of one or more fields

that uniquely identify each record that you store in the table. Often, there is a unique identification number,

such as an ID number, a serial number, or a code, that serves as a primary key. For example, you might

have a Customers table where each customer has a unique customer ID number. The customer ID field is

the primary key of the Customers table. When a primary key contains more than one field, it is usually

composed of pre-existing fields that, taken together, provide unique values. For example, you might use a

combination of last name, first name, and birth date as the primary key for a table about people.

 Foreign key    A table can also have one or more foreign keys. A foreign key contains values that

correspond to values in the primary key of another table. For example, you might have an Orders table in

which each order has a customer ID number that corresponds to a record in a Customers table. The

customer ID field is a foreign key of the Orders table.

The correspondence of values between key fields forms the basis of a table relationship. You use a table
relationship to combine data from related tables. For example, suppose that you have a Customers table
and an Orders table. In your Customers table, each record is identified by the primary key field, ID.

To associate each order with a customer, you add a foreign key field to the Orders table that corresponds to
the ID field of the Customers table, and then create a relationship between the two keys. When you add a
record to the Orders table, you use a value for customer ID that comes from the Customers table. Whenever
you want to view any information about an order's customer, you use the relationship to identify which data
from the Customers table corresponds to which records in the Orders table.

A table relationship, shown in the Relationships window.

 A primary key, identified by the key icon next to the field name.

 A foreign key — note the absence of the key icon.


A superkey is a combination of attributes that can be uniquely used to identify a database
record. A table might have many superkeys. Candidate keys are a special subset of
superkeys that do not have any extraneous information in them.
Examples:
Imagine a table with the fields <Name>, <Age>, <SSN> and <Phone Extension>. This
table has many possible superkeys. Three of these are <SSN>, <Phone Extension, Name>
and <SSN, Name>. Of those listed, only <SSN> is a candidate key, as the others contain
information not necessary to uniquely identify records.
Keys are crucial to a table structure for many reasons, some of which are identified below:
 They ensure that each record in a table is precisely identified.
 They help establish and enforce various types of integrity.
 They serve to establish table relationships.
Now let's see how you should choose your key(s). First, let's make up a little table to look at:

PersonID LastName FirstName D.O.B

1 Smith Robert 01/01/1970

2 Jones Robert 01/01/1970

4 Smith Henry 01/01/1970

5 Jones Henry 01/01/1970


A superkey is a column or set of columns that uniquely identify a record. This table has many superkeys:
 PersonID
 PersonID + LastName
 PersonID + FirstName
 PersonID + DOB
 PersonID + LastName + FirstName
 PersonID + LastName + DOB
 PersonID + FirstName + DOB
 PersonID + LastName + FirstName + DOB
 LastName + FirstName + DOB
All of these will uniquely identify each record, so each one is a superkey. Of those keys, a key which is comprised of
more than one column is a composite key; a key of only one column is a simple key.
A candidate key is a superkey that has no unique subset; it contains no columns that are not necessary to make it
unique. This table has 2 candidate keys:
 PersonID
 LastName + FirstName + DOB
Not all candidate keys make good primary keys: Note that these may work for our current data set, but would likely be
bad choices for future data. It is quite possible for two people to share a full name and date of birth.
We select a primary key from the candidate keys. This primary key will uniquely identify each record. It may or may
not provide information about the record it identifies. It must not be Null-able, that is if it exists in a record it can not
have the value Null. It must be unique. Itcan not be changed. Any candidate keys we do not select become alternate
keys.
We will select (PersonID) as the primary key. This makes (LastName + FirstName + DOB) an alternate key.

5)Define data type. Name diff. data types available. How OLE is diff. from attachment
data type and hyperlink?

Every table is made up of fields (field: An element of a table that contains a specific item of information, such
as a last name. A Title field might contain Mr. or Ms. Databases such as Microsoft SQL Server refer to fields
as columns.). The properties of a field describe the characteristics and behavior of data added to that field. A
field's data type is the most important property because it determines what kind of data the field can store.

A field's data type determines many other important field qualities, such as the following:

 Which formats can be used with the field.

 The maximum size of a field value.

 How the field can be used in expressions.

 Whether the field can be indexed.

The field's data type can be predefined or you will select a data type depending on how you create the new
field. For example, if you create a field from the Datasheet view and:

 Use an existing field from another table, the data type is already defined in the template or in the

other table.

 Enter data in a blank column (or field), Access 2010 assigns a data type to the field based on the

values that you enter or you can assign the data type and format for the field.

 On the Modify Fields tab, in the Fields & Columns group, click Add Fields, Access 2010 displays

a list of data types that you can select from.


 The available data types in Access 2010 are, Basic Types, Number, Data and Time, Yes/No,
and Quick Start . The following tables show you the formats available for each data type and
explain the effect of the formatting option.

 Basic Types
FORMAT USE TO DISPLAY
Text Short, alphanumeric values, such as a last name or a street address.
Number Numeric values, such as distances. Note that there is a separate data type for currency.
Currency Monetary values.
Yes/No Yes and No values and fields that contain only one of two values.
Date/Time Date and Time values for the years 100 through 9999.
Rich Text Text or combinations of text and numbers that can be formatted using color and font controls.
Calculated Results of a calculation. The calculation must refer to other fields in the same table. You would use the
Field Expression Builder to create the calculation.
Attachment Attached images, spreadsheet files, documents, charts, and other types of supported files to the records in your
database, similar to attaching files to e-mail messages.
Hyperlink Text or combinations of text and numbers stored as text and used as a hyperlink address.
Memo Long blocks of text. A typical use of a Memo field would be a detailed product description.
Lookup Displays either a list of values that is retrieved from a table or query, or a set of values that you specified when
you created the field. The Lookup Wizard starts and you can create a Lookup field. The data type of a Lookup
field is either Text or Number, depending on the choices that you make in the wizard.
 NOTE    Lookup fields have an additional set of field properties, which are located on the Lookup tab in the
Field Properties pane.

 Number
FORMAT USE TO DISPLAY
General Numbers without additional formatting exactly as it is
stored.
Currency General monetary values.
Euro General monetary values stored in the EU format.
Fixed Numeric data.
Standard Numeric data with decimal.
Percentag Percentages.
e
Scientific Calculations.

 Data and Time


FORMAT USE TO DISPLAY
Short Date Display the date in a short format. Depends on your regional date and time settings. For example, 3/14/2001 for
USA.
Medium Display the date in medium format. For example, 3-Apr-09 for USA.
Date
Long Date Display the date in a long format. Depends on your the regional date and time settings. For example,
Wednesday, March 14, 2001 for USA.
Time am/pm Display the time only using a 12 hour format that will respond to changes in the regional date and time settings.
Medium Display the time followed by AM/PM.
Time
Time 24hour Display the time only using a 24 hour format that will respond to changes in the regional date and time settings

 Yes/No
DATA TYPE USE TO DISPLAY
Check Box A check box.
Yes/No Yes or No options
True/False True or False options.
On/Off On or Off options.

 Quick Start
DATA TYPE USE TO DISPLAY
Address Fields for the entire postal address.
Phone Fields for the Home Phone, Mobile Phone, and the Work Phone.
Priority A drop-down box with the following priority options: Low, Medium, High.
Status A drop-down box with the following options: Not Started, In Progress, Completed,
Cancelled.
Tags Displays up to three tags.
 OLE Object    OLE objects (OLE object: An object supporting the OLE protocol for object linking
and embedding. An OLE object from an OLE server (for example, a Windows Paint picture or a
Microsoft Excel worksheet) can be linked or embedded in a field, form, or report.), such as Word
documents.

ATTACHMENT

Purpose    Use an attachment field to attach multiple files, such as images, to a record.

Suppose that you have a job contacts database. You can use an attachment field to attach a photo of each
contact, and you can also attach one or more resumes for a contact to the same field in that record.

For some file types, Access compresses each attachment as you add it.

Types of attachments that Access compresses

 Bitmaps, such as .bmp files

 Windows Metafiles, including .emf files

 Exchangeable File Format files (.exif files)

 Icons

 Tagged Image File Format files

You can attach many kinds of files to a record. However, some file types that may pose security risks are
blocked. As a rule, you can attach any file that was created in one of the 2007 Microsoft Office system
programs. You can also attach log files (.log), text files (.text, .txt), and compressed .zip files. For a list of
supported image file formats, see the table later in this section.

HYPERLINK

Purpose    Use to store a hyperlink, such as an e-mail address or a Web site URL.

A hyperlink can be a path or a . It can store up to 2048 characters.

Supported field properties


PROPERTY USE
Allow Zero Allows entry (by setting to Yes) of a zero-length string ("") in a Hyperlink, Text, or Memo field.
Length
Append Only Determines whether to track field value changes. There are two settings:

Yes   Tracks changes. To view the field value history, right-click the field, and then click Show
column history.
No   Does not track changes.

 WARNING    Setting this property to No deletes any existing field value history.

Caption The label text that is displayed for this field by default in forms, reports, and queries. If this property is empty,
the name of the field is used. Any text string is allowed.
 TIP    An effective caption is usually brief.

Default Value Automatically assigns the specified value to this field when a new record is added.
Format Determines the way that the field appears when it is displayed or printed in datasheets or in forms or reports
that are bound to the field. You can define a custom format for a Hyperlink field.
IME Mode Controls the conversion of characters in East Asian versions of Windows.
IME Sentence Controls the conversion of sentences in East Asian versions of Windows.
Mode
Indexed Specifies whether the field has an . There are three available values:

Yes (No duplicates)   Creates a unique index on the field.


Yes (Duplicates OK)   Creates a non-unique index on the field.
No   Removes any index on the field.

 NOTE    Do not change this property for a field that is used in a primary key.
Although you can create an index on a single field by setting the Indexed field property, some kinds of
indexes cannot be created in this manner. For example, you cannot create a multi-field index by setting this
property.
Required Requires that data be entered in the field.
Smart Tags Attaches a smart tag to the field.
Text Align Specifies the default alignment of text within a control.
Unicode Compresses text that is stored in this field when less than 4,096 characters are stored.
Compression
Validation Rule Supplies an expression that must be true whenever you add or change the value in this field. Use in
conjunction with the Validation Text property.
Validation Text Enter a message to display when a value that is entered violates the expression in the Validation Rule
property.

OLE OBJECT

Purpose    Use to attach an OLE Object, such as a Microsoft Office Excel spreadsheet, to a record. If you
want to use features, you must use the OLE Object data type.

In most cases, you should use an Attachment field instead of an OLE Object field. OLE Object fields support
fewer file types than Attachment fields support. In addition, OLE Object fields do not let you attach multiple
files to a single record.

Supported field properties


PROPERTY USE
Caption The label text that is displayed for this field by default in forms, reports, and queries. If this property is empty, the
name of the field is used. Any text string is allowed.
 TIP    An effective caption is usually brief.

Required Requires that data be entered in the field.


Text Align Specifies the default alignment of text within a control.

(Refer text)

6) What is relationship in ms access? How many types are there?

the fields in the tables must be coordinated so that they show information about the same order. This
coordination is accomplished by using table relationships. A table relationship works by matching data in key
fields — often a field with the same name in both tables. In most cases, these matching fields are the
primary key from one table, which provides a unique identifier for each record, and a foreign key in the
other table.

There are three types of table relationships.

 A one-to-many relationship

Consider an order tracking database that includes a Customers table and an Orders table. A
customer can place any number of orders. It follows that for any customer represented in the
Customers table, there can be many orders represented in the Orders table. The relationship
between the Customers table and the Orders table is, therefore, a one-to-many relationship.

To represent a one-to-many relationship in your database design, take the primary key on the "one"
side of the relationship and add it as an additional field or fields to the table on the "many" side of the
relationship. In this case, for example, you add a new field — the ID field from the Customers
table — to the Orders table and name it Customer ID. Access can then use the Customer ID number
in the Orders table to locate the correct customer for each order.

 A many-to-many relationship

Consider the relationship between a Products table and an Orders table. A single order can include
more than one product. On the other hand, a single product can appear on many orders. Therefore,
for each record in the Orders table, there can be many records in the Products table. In addition, for
each record in the Products table, there can be many records in the Orders table. This type of
relationship is called a many-to-many relationship because, for any product, there can be many
orders and, for any order, there can be many products. Note that to detect existing many-to-many
relationships between your tables, it is important that you consider both sides of the relationship.

To represent a many-to-many relationship, you must create a third table, often called a junction
table, that breaks down the many-to-many relationship into two one-to-many relationships. You insert
the primary key from each of the two tables into the third table. As a result, the third table records
each occurrence, or instance, of the relationship. For example, the Orders table and the Products
table have a many-to-many relationship that is defined by creating two one-to-many relationships to
the Order Details table. One order can have many products, and each product can appear on many
orders.

 A one-to-one relationship

In a one-to-one relationship, each record in the first table can have only one matching record in the
second table, and each record in the second table can have only one matching record in the first
table. This type of relationship is not common because, most often, the information related in this
way is stored in the same table. You might use a one-to-one relationship to divide a table with many
fields, to isolate part of a table for security reasons, or to store information that applies only to a
subset of the main table. When you do identify such a relationship, both tables must share a
common field.

Relatonships are required because:

 Table relationships inform your query designs

To work with records from more than one table, you often must create a query that joins the tables.
The query works by matching the values in the primary key field of the first table with a foreign key
field in the second table. For example, to return rows that list all of the orders for each customer, you
construct a query that joins the Customers table with the Orders table based on the Customer ID
field. In the Relationships window, you can manually specify the fields to join. However, if you
already have a relationship defined between the tables, Access supplies the default join, based on
existing the table relationship. In addition, if you use one of the query wizards, Access uses the
information it gathers from the table relationships you have already defined to present you with
informed choices and to prepopulate property settings with appropriate default values.

 Table relationships inform your form and report designs

When you design a form or report, Access uses the information it gathers from the table relationships
you have already defined to present you with informed choices and to prepopulate property settings
with appropriate default values.

 Table relationships are the foundation upon which you can enforce referential integrity to help

prevent orphan records in your database. An orphan record is a record with a reference to another record

that does not exist — for example, an order record that references a customer record that does not exist.
When you design a database, you divide your information into tables, each of which has a primary
key. You then add foreign keys to related tables that reference those primary keys. These foreign
key-primary key pairings form the basis for table relationships and multi-table queries. It is important,
therefore, that these foreign key-primary key references stay synchronized. Referential integrity
helps ensure that references stay synchronized and is dependent upon table relationships.

7) What do you mean by integrity? How many types of integrity constraints are there?
Explain each with example.

Integrity constraints are a set of data validation rules that you can specify in order to restrict the
data values that can be stored for a variable in a SAS data file. Integrity constraints help you
preserve the validity and consistency of your data. SAS enforces the integrity constraints when
the values associated with a variable are added, updated, or deleted.
There are two categories of integrity constraints: general and referential.

General Integrity Constraints


General integrity constraints enable you to restrict the values of variables within a single file.
There are four types of general constraints:
Check limits the data values of variables to a specific set, range, or list of values. Check
constraints can also be used to ensure that the data values in one variable within an
observation are contingent on the data values of another variable in the same
observation.
not null requires that a variable contain a data value. Null (missing) values are not allowed.
Unique requires that the specified variable or variables contain unique data values. A null data
value is allowed but is limited to a single instance.
primary requires that the specified variable or variables contain unique data values and that null
key data values are not allowed. Only one primary key can exist in a data file.
Note:   A primary key is a general integrity constraint if it does not have any foreign key
constraints referencing it.  

Referential Integrity Constraints


A referential integrity constraint is created when a primary key integrity constraint in one data file
is referenced by a foreign key integrity constraint in another data file.

The foreign key constraint links the data values of one or more variables in the foreign key data
file, to corresponding variables and values in the primary key data file. Data values in the foreign
key data file must have a matching value in the primary key data file, or they must be null. When
data is updated or deleted in the primary key data file, the modifications are controlled by a
referential action that is defined as part of the foreign key constraint.

Separate referential actions can be defined for the update and delete operations. There are three
types of referential actions:
Restrict prevents the data values of the primary key variables from being updated or deleted if
there is a matching value in one of the foreign key data file's corresponding foreign key
variables. The restrict type of action is the default action if one is not specified.
set null enables the data values of the primary key variables to be updated or deleted, but
matching data values in the foreign key data files are changed to null (missing) values.
Cascad enables the data values in the primary key variables to be updated, and additionally
e updates matching data values in the foreign key data files to the same value. The
cascade type of action is supported only for update operations.

The requirements for establishing a referential relationship are as follows:

 The primary key and foreign key must reference the same number of variables, and the
variables must be in the same order.

 The variables must be of the same type (character or numeric) and length.

 If the foreign key is being added to a data file that already contains data, the data values
in the foreign key data file must either match existing values in the primary key data file, or the
values must be null.

(Refer text and other classmates)

8) What do you mean by cascade update and cascade delete. When do we make use of
them?

Understand that cascading updates or cascading deletes are used to overrule referential
integrity rules while retaining relationship integrity. These conditions only apply
to relationships in which referential integrity is enforced.
2
Know that by selecting Cascade Update Related Fields checkbox when you are defining a
relationship, a subsequent change to a record will automatically generate an update in all
related records.
3
Understand that by selecting Cascade Delete Related Fields checkbox when you are
defining a relationship, a subsequent deletion of a record will automatically cause a deletion
of all related records.

Microsoft Access also provides methods to override this default behaviour for established
relationships. The Microsoft Access Relationships toolbar provides two check boxes, Cascade
Update Related Fields and Cascade Delete Related Records, as options to override the default
behaviour. Both options are applicable to tables where referential integrity has already been
established.
The Cascade Update Related Fields option allows you to change the primary key value (parent)
of the primary table and have that change cascade down to the foreign key value (child) of the
foreign key table. This option is only applicable to primary keys that consist of a number or text
value. The Cascade Update Related Fields option has no effect when the primary key is a unique
index, generated by the Microsoft Access auto-number feature. Auto-number values cannot be
changed. You must be careful to ensure that a foreign key value is defined to correspond with the
primary key value that is being changed. If Microsoft Access does not find a corresponding
foreign key value in the corresponding child table, Microsoft Access will provide no indication
that the cascade has failed. It will only update the primary key value.
The Cascade Delete Related Records option allows you to delete a primary record (parent) from
the primary table even if related, foreign records (child) exist in the foreign table. Microsoft
Access will automatically delete the related foreign records to maintain integrity of the tables. If
you attempt to delete a primary record and there are no related foreign records, Microsoft Access
produces a warning message that gives no indication that the cascade has failed. The warning will
allow hyou the option of continuing with the deletion of just the primary record or aborting the
process. When Microsoft Access is able to detect the presence of related foreign records, you will
be issued a message indicating Microsoft Access’s intent to delete records from both the primary
and foreign tables. You should carefully consider all options before implementing this override.
Deleting records from either primary or foreign tables may have detrimental effects on other
fields, in your database, that rely on or make calculations based on data contained in these
records. You may find it more appropriate to archive the data or modify data in the record fields
to reflect unavailability or null values.
9) Name the field properties in table we usually set?
(Refer notes and from others)
10) What is difference between field validation and record validation? What is the
difference between validation rule and text.

You can vet or validate data as it is input to help improve accuracy and consistency, by using validation
rules. There are three ways to use validation rules:

 Field Validation Rule You can use a validation rule to specify a criterion that all valid field values

must meet. For example, a date field might have a validation rule that disallows values in the past.

 Record Validation Rule You can use a validation rule to specify a condition that all valid records

must satisfy. For example, a record with two date fields might require that values of one field always precede

values of the other field (e.g., StartDate is before EndDate).

 Validation on a form You can use the Validation Rule property of a control on a form to specify a

criterion that all values input to that control must meet. The Validation Rule control property works like a

Field Validation Rule.

Access provides a number of ways to restrict input:


 Data types    Every table field has a data type that restricts what users can enter. For example, a

Date/Time field accepts only dates and times, a Currency field accepts only monetary data, and so on.

 Field prhoperties    Some field properties restrict data input. For example, the Field Size property

of a field restricts input by limiting the amount of data.

You can also use the Validation Rule property to require specific values, and the Validation Text
property to alert your users to any mistakes. For example, entering a rule such as >100 And<1000 in
the Validation Rule property forces users to enter values between 100 and 1,000. A rule such as
[EndDate]>=[StartDate] forces users to enter an ending date that occurs on or after a starting date.
Entering text such as "Enter values between 100 and 1,000" or "Enter an ending date on or after the
start date" in the Validation Text property tells users when they have made a mistake and how to fix
the error.

 Input masks    You can use an input mask to validate data by forcing users to enter values in a

specific way. For example, an input mask can force users to enter dates in a European format, such as

2007.04.14.

You can use these methods of validating data alone or in combination with each other. Data types are not
optional, and provide the most basic type of data validation.

 Field validation rules    Use a field validation rule to check the value that you enter in a field when

you leave the field. For example, suppose you have a Date field, and you enter >=#01/01/2010# in the

Validation Rule property of that field. Your rule now requires users to enter dates on or after January 1,

2010. If you enter a date earlier than 2010 and then try to place the focus on another field, Access prevents

you from leaving the current field until you fix the problem.

 Record validation rules    Use a record validation rule to control when you can save a record (a

row in a table). Unlike a field validation rule, a record validation rule refers to other fields in the same table.

You create record validation rules when you need to check the values in one field against the values in

another. For example, suppose your business requires you to ship products within 30 days and, if you don't

ship within that time, you must refund part of the purchase price to your customer. You can define a record

validation rule such as [RequiredDate]<=[OrderDate]+30 to ensure that someone doesn't enter a ship date

(the value in the RequiredDate field) too far into the future.
11) What is an input mask? How do we use it?

When you have several people entering data in your database, you can define how users must enter data in
specific fields to help maintain consistency and to make your database easier to manage. For example, you
can set an input mask for a form so that users can only enter telephone numbers in the Swedish format or
addresses in the French format. You can set a specific format for the input mask, and select another format
so that the same data is displayed differently.

You can add input masks to table fields, queries, and to form and report controls.

For example, you can add an input mask to a Date/Time field in a table, or to a text box control on a form
that you bind to a Date/Time field. You can also add input masks to form controls, such as text boxes, that
you bind to table fields that are set to those data types. If you are unfamiliar with data types, see the article
Introduction to data types and field properties.

Input masks provide a set format for data entry in a field by using characters and symbols. When you apply
an input mask to a field, anyone who inputs data in that field must follow the specific pattern defined by the
input mask. For example, if the database user enters a phone number without the area code, in this
particular mask, (___) 555-0187 xt. ___ the user will be unable to save the data until the area code data is
added. The exact behavior depends on the how the database designer sets up the input mask.

Input masks provide a large amount of data validation and prevent users from entering invalid data (such as
a phone number in a date field). Input masks can also help ensure that users enter data in a consistent way.
That consistency can make data easier to find and make it easier to maintain your database.

Remember that you define input masks to control the format in which data is entered in the database but
you can apply another format to the same data to change how the data is displayed. For example, your input
mask can define dates to be entered in a format such as YYYY.MM.DD, but have the date appear as DD-
MMM-YYYY.

(Refer text and others)


12) Why and how we make use of lookup wizard?

You can use the Lookup Wizard to create a field that is based on a table or query, or that is based on a list
of values that you type. This section describes the steps of the Lookup Wizard.

CREATE A MULTIVALUED LOOKUP BASED ON A TABLE OR QUERY


1. In the Lookup Wizard, click I want the lookup field to look up the values in a table or query,
and then click Next.

2. Select a table or query from the list, and then click Next.

3. Under Available Fields, click the fields that you want included in your lookup.
4. Click the "greater than" button (>) to move the fields you chose to the Selected Fields list. Click the
double "greater than" button (») to move all of the fields to the Selected Fields list, and then click
Next.

5. Optionally, select one to four fields on which to sort the lookup items, and then click Next.

6. Adjust the width of the columns in your lookup field, if necessary, and then click Next.

7. Under Do you want to store multiple values for this lookup?, select the Allow Multiple Values
check box.

 NOTE    This check box must be selected to enable storing multiple values.
8. Click Finish.

When you click Finish, a lookup field is created whose field properties are set based on the
choices you made in the Lookup Wizard.

9. To save the table, on the File tab, click Save.

Keyboard shortcut  CTRL+S

CREATE A MULTIVALUED LOOKUP BASED ON VALUES THAT YOU ENTER


1. In the Lookup Wizard, click I will type in the values that I want, and then click Next.

2. Enter the number of columns. Then, type each value. To move to the next column or row, press
TAB.

 NOTE     If you want to be able to edit the value list, use only one column.

3. When you are finished entering values, click Next.

4. If you specified more than one column at step 2, you must choose which column you will use to
uniquely identify each value. In the Available Fields box, double-click the column that you want to use
to uniquely identify each value.

 NOTE    This step does not appear if you did not specify more than one column at step 2.

5. In the Lookup Wizard, type the label for your lookup field.
6. Under Do you want to store multiple values for this lookup?, select the Allow Multiple Values
check box.

 NOTE    This check box must be selected to enable storing multiple values.

7. Click Finish.

8. To save the table, on the File tab, click Save.

Keyboard shortcut  CTRL+S

After you create the multivalued field, it appears as a check box drop-down list in Datasheet view.

(Refer Text and others)


13) Why and how do we use format field property?
Every field (field: An element of a table that contains a specific item of information, such as a last
name. A Title field might contain Mr. or Ms. Databases such as Microsoft SQL Server refer to fields
as columns.) in a table has properties. These properties define the field's characteristics and
behavior. The most important property for a field is its data type. A field's data type determines
what kind of data it can store. For example, a field whose data type is Text can store data that
consists of either text or numerical characters, but a field whose data type is Number can store
only numerical data.

A field's data type determines many other important field qualities, such as:

 How you can use the field in expressions.


 The maximum size of a field value.
 Whether the field can be indexed.
 Which formats can be used with the field.

When you create a new field in Design view (Design view: A view that shows the design of these
database objects: tables, queries, forms, reports, and macros. In Design view, you can create new
database objects and modify the design of existing objects.), you specify the field's data type and,
optionally, its other properties.

Contacts table open in Design view


 Data type
 Field properties
When you create a field in Datasheet view (Datasheet view: A view that displays data from a table,
form, query, view, or stored procedure in a row-and-column format. In Datasheet view, you can
edit fields, add and delete data, and search for data.), the field's data type is defined for you. If
you create a field in Datasheet view by using a field template or by using an existing field from
another table, the data type is already defined in the template or in the other table. If you create a
field by entering data in Datasheet view, Microsoft Office Access assigns a data type to the field
based on the values that you enter. If you enter values that are of different data types in the field,
Access may prompt you to make a decision about the data type.

You can change the field's data type and its Format, Indexed, and Required field properties in
Datasheet view.

Contacts table open in Datasheet view


 Create a field by entering data in an empty column.
 Adjust the field's data type and other properties by using the Datasheet tab on
the Ribbon.

This field property determines the display layout for the field. We can feed in either a
pre-defined format or enter a custom format. The preset ones are- general, currency, euro,
fixed, standard, percentage, and scientific.
(refer notes and others)
14) Define calculated field. How do they get value?
A calculated field takes information from another field in your Microsoft Access 2007 database
and performs some arithmetic to come up with new information. In fact, a calculated field can take
data from more than one field and combine information to create an entirely new field if that's
what you want. You can perform simple arithmetic, like addition and multiplication, or use
Access's built-in functions, such as Sum and Avg (average), for more difficult calculations.
1. Click an empty column in the Field row of the query grid.
The good old cursor will blink in the row. Access puts the results of the calculation in the same
grid position as the calculation itself, so if the calculation sits in the third column of your query
grid, the calculation's results will be in the third column, too.

Experience 2. Enter a name for your calculation followed by a colon (:).


Access will refer to this calculation from now on by whatever you enter before the colon. Keep it
short and sweet, like Amount or Tax, so it's easier to refer to later on. If you don't name your
calculation, Access will put the generic Expr (followed by a number) as its name. It has to be
called something, so why not Expr1 or Expr2, right?

3. Enter your calculation, substituting field names for the actual numbers where
necessary.
You don't have to exclusively use field names in your calculations. You can also enter formulas
with numbers, like this:
Tax: Quantity * UnitPrice * .06

If a field name contains more than one word, put square brackets around it. Access treats
anything else it finds in the calculation as a constant (which is math lingo for it is what it is and it
never changes). If the field name contains no spaces, Access will put the square brackets in for
you after you enter the field name. That's why you should always use one-word field names — so
you don't have to type those darned square brackets.

When creating formulas, keep these general guidelines in mind:

 You must manually type the field names and constants into your
formula. You can't just drag and drop stuff from the table list.
 Don't worry if your calculation grows past the edge of the Field box.
Access still remembers everything, even if it doesn't appear on the screen.

To make the query column wider, aim the mouse pointer at the line on the right
side of the thin bar above the calculation entry. When you get it right over the
line, the pointer changes into a line with a horizontal arrow through it. When that
happens, click and drag the mouse to the right. As you do, the column expands
according to your movements. To fit the width to just the right size, position the
mouse to size the column as described above then double-click!

 If it's a really, really, really long calculation, press Shift+F2 while the
cursor is somewhere on the calculation.

This opens the Zoom dialog box so that you can easily see and edit everything in
a pop-up window.

When you run a query containing a calculation, Access

 Produces a datasheet showing the fields you specified


 Adds a new column for each calculated field

15) What is query in MS Access? How select query is different from action query?

A query is a more powerful and flexible way of selecting,filtering and sorting


records.A query is created by specifying fields to display from the data source(a
table or another query).Typically a query also specifies,what data to look for,in
one or more fields (criteria).When u run a query,Access creates a record
set,essentially a table containing the data matching the criteria u
specified.However,unlike a real table,a record set each time the query is
run.Withaqueryypu can:

1.Extract records according to your criteria you specify.

2.Choose the fields ypu want to view in theresult.

3.Sort the records in a specific order.

4.Calculate fields and summarize data.

5.Create a query using the simple query wizard.

There are four types of action queries: , , , and . Except for make-table queries
(which create new tables), action queries make changes to the data in tables
they are based on. These changes cannot be easily undone, for example, by
pressing CTRL+Z. If you make changes using an action query that you later
decide you didn't want to make, usually you will have to restore the data from a
backup copy. For this reason, you should always make sure you have a fresh
backup of the underlying data before running an action query.

You use and to retrieve and present data, and to supply forms and reports with
data. When you run a select or a crosstab query, Microsoft Office Access 2007
displays the results in .

16) How many types of aggregate functions are there?how we use them?

Using the , you can determine various statistics on sets of values. You can use
these functions in a query and aggregate expressions in the SQL property of a
QueryDef object or when creating a Recordset object based on an SQL query.

Avg Function

Count Function

First, Last Functions


Min, Max Functions

StDev, StDevP Functions

Sum Function

Var, VarP Functions

The Access 2007 aggregate functions calculate values over a range of data. The
totals row is new with Access 2007 and makes it easier to use aggregate
functions such as averages, counts, sums and totals. You may still use these
functions in queries and Visual Basic Applications as before but the "Totals" row
is generally faster.
The following steps will show how the use the Access 2007 aggregate functions.
Difficulty: Moderate

Instructions

1. 1

Add a "Totals" row to a query result, table or form that contains a datasheet. Look on the
"Navigation Pane" for the database object you are interested in and right-click on that icon.
Click on "Form View" in the "Shortcut" menu if it is a form, otherwise click on "Design View."

2. 2

Select the "Home" tab and look in the "Records" group for the "Totals" icon. Click this icon
and you should see a "Total" row appear just below the asterisk row in your database object.

3. 3

Click on the field in the "Total" row on which you wish to perform an aggregate function. This
should display a drop-down list of the aggregate functions available for that field. The
aggregate functions for a numerical field should be Sum, Average, Count, Maximum,
Minimum, Standard Deviation and Variance.

4. 4

Watch the value for the aggregate function appear in the selected field of the total field.

5. 5

Remove the Totals row by clicking on the "Totals" icon as before in Step 2. Note that this
merely suppresses the display of the "Totals" row and does not actually delete it. Subsequent
clicking of the "Totals" icon will turn the "Totals" row on and off.
17) Diff. b/w query and filter.
Queries and filters both refine a group of messages into a subset, but queries yield a
subset of all the messages in the Microsoft System Center Configuration Manager
2007 site database, while filtering yields a subset of the messages currently
displayed in ConfigMgr Status Message Viewer. For example, if there are 1,000
messages in the Configuration Manager 2007 site database, you could define a query
that returns 541 of those messages to ConfigMgr Status Message Viewer. You could
then filter these messages so that only 17 are displayed.

A filter basically restricts the view of data of a single table. You are still viewing/editing
the same table, albeit through a filter.

A query can involve just one table, or it can involve multiple tables. And it will generate
a NEW answer. Changing the answer will not affect the original data.
A query you can save and reuse just by clicking on it. You can also create queries and
reports based on querys
A filter is a temporary setting and cannot be used in reports and other queries

18) Explain diff. types of controls available.


19) Explain the various controls we have( Text box, label box etc.)

20) Explain the various sections in forms.


The information in a form can be divided into sections. All forms have a detail section (detail
section: Used to contain the main body of a form or report. This section usually contains controls
bound to the fields in the record source but can also contain unbound controls, such as labels
that identify a field's contents.), but a form can also include form header, page header (page
header: Used to display a title, column headings, dates, or page numbers at the top of every page
in a form or report. In a form, the page header appears only when you print the form.), page
footer (page footer: Used to display page summaries, dates, or page numbers at the bottom of
every page in a form or report. In a form, the page footer appears only when you print the form.),
and form footer sections. Each section has a specific purpose and prints in a predictable order in
the form.
In Design view (Design view: A view that shows the design of these database objects: tables,
queries, forms, reports, and macros. In Design view, you can create new database objects and
modify the design of existing objects.), sections are represented as bands, and each section that
the form contains is represented once. In a printed form, the page header and footer might be
repeated once for each page. You determine where information appears in every section by
placing controls (control: A graphical user interface object, such as a text box, check box, scroll
bar, or command button, that lets users control the program. You use controls to display data or
choices, perform an action, or make the user interface easier to read.), such as labels (label: A
control that displays descriptive text, such as a title, a caption, or instructions, on a form or report.
Labels may or may not be attached to another control.) and text boxes (text box: A control, also
called an edit field, that is used on a form or report to display text or accept data entry. A text box
can have a label attached to it.).
This illustration shows the Add Products form in Design view.

A form header displays information that remains the same for every record, such as a
title for the form. A form header appears at the top of the screen in Form view (Form view: A view
that displays a form to show or accept data. Form view is the primary means of adding and
modifying data in tables. You can also change the design of a form in this view.) and at the top of
the first page when printed.

A page header displays information such as a title or column headings at the top of
every printed page. Page headers appear only on printed forms.

A detail section displays records. You can either display one record on the screen or
page, or display as many as will fit.

A page footer displays information such as the date or page number at the bottom of
every printed page. Page footers appear only on printed forms.

A form footer displays information that remains the same for every record, such as
command buttons (command button: A control that runs a macro, calls a Visual Basic function, or
runs an event procedure. A command button is sometimes called a push button in other
programs.) or instructions for using the form. A form footer appears at the bottom of the screen
in Form view or after the last detail section on the last page when printed.

This illustration shows the Add Products form as it will appear when printed.
The form header prints at the top of the first page.

The page header prints at the top of every page, but appears only when printed or in
Print Preview.

The detail section prints the data from the record source.

This illustration shows the Add Products form in Form view.

The form header displays a title.

The detail section displays data from the record source.

A subform (subform: A form contained within another form or a report.) can also have sections.
For example, this subform has a form header and a form footer, in addition to the detail section.

Form header

Form footer
Detail section

Subform

You can hide or resize a section, add a picture, or set the background color of a section. You can
also set section properties to customize how the contents of a section will print.

21) Explain various sections in Reports.

In Access, the design of a report is divided into sections. You can view your
report in Design view to see its sections. To create useful reports, you need to
understand how each section works. For example, the section in which you
choose to place a calculated control determines how Access calculates the
results. The following list is a summary of the section types and their uses:

Report Header   This section is printed just once, at the beginning of


the report. Use the report header for information that might normally
appear on a cover page, such as a logo, a title, or a date. When you place
a calculated control that uses the Sum aggregate function in the report
header, the sum calculated is for the entire report. The report header is
printed before the page header.

Page Header   This section is printed at the top of every page. For
example, use a page header to repeat the report title on every page.

Group Header   This section is printed at the beginning of each new


group of records. Use the group header to print the group name. For
example, in a report that is grouped by product, use the group header to
print the product name. When you place a calculated control that uses the
Sum aggregate function in the group header, the sum is for the current
group.

Detail   This section is printed once for every row in the record source.
This is where you place the controls that make up the main body of the
report.
Group Footer   This section is printed at the end of each group of
records. Use a group footer to print summary information for a group.

Page Footer   This section is printed at the end of every page. Use a
page footer to print page numbers or per-page information.

Report Footer   This section is printed just once, at the end of the report. Use
the report footer to print report totals or other summary information for the entire
report.
22) Different orientations in reports.
23) How many ways can query, forms and reports be created? State the diff. in the
design.
24) What is rdbms? List some database objects available in access.

(RDBMS) are database management systems that maintain data records and indices in
tables. Relationships may be created and maintained across and among the data and
tables.RDBMS stands for Relational Database Management System. RDBMS is the basis for SQL, and
for all modern database systems like MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.

A Relational database management system (RDBMS) is a database management system (DBMS) that is
based on the relational model as introduced by E. F. Codd.

When you create a database, Access offers you Tables, Queries, Forms, Reports, Macros, and
Modules. Here's a quick overview of what these are and when to use them.

Tables.All data is stored in tables. When you create a new table, Access asks you define
fields (column headings), giving each a unique name, and telling Access the data type. Use the
"Text" type for most data, including numbers that don't need to be added e.g. phone numbers
or postal codes. Using Wizards, Access will walk you through the process of creating common
tables such as lists of names and addresses. Once you have defined a table's structure, you can
enter data. Each new row that you add to the table is called a record. To define relationships
between tables:

 in Access 2007 or later:  Database Tools | Relationships,


 in Access 95 — 2003:  Tools | Relationships,
 in Access 1 — 2:  Edit | Relationships.

Queries.Use a query to find or operate on the data in your tables. With a query, you can
display the records that match certain criteria (e.g. all the members called "Barry"), sort the
data as you please (e.g. by Surname), and even combine data from different tables. You can
edit the data displayed in a query (in most cases), and the data in the underlying table will
change. Special queries can also be defined to make wholesale changes to your data, e.g.
delete all members whose subscriptions are 2 years overdue, or set a "State" field to "WA"
wherever postcode begins with 6.
Forms.These are screens for displaying data from and inputting data into your tables.
The basic form has an appearance similar to an index card: it shows only one record at a time,
with a different field on each line. If you want to control how the records are sorted, define a
query first, and then create a form based on the query. If you have defined a one-to-many
relationship between two tables, use the "Subform" Wizard to create a form which contains
another form. The subform will then display only the records matching the one on the main
form.

Reports.If forms are for input, then reports are for output. Anything you plan to print
deserves a report, whether it is a list of names and addresses, a financial summary for a
period, or a set of mailing labels. Again the Access Wizards walk you through the process of
defining reports.

Pages (Access 2000 - 2003). Use pages to enter or display data via Internet. Pages are
stored as HTML files, with data read from and written to the database. Michael Kaplan has
published a free utility to convert Access forms and reports into Data Access Pages. (Pages
were deprecated in Access 2007.)

Macros.An Access Macro is a script for doing some job. For example, to create a button
which opens a report, you could use a macro which fires off the "OpenReport" action. Macros
can also be used to set one field based on the value of another (the "SetValue" action), to
validate that certain conditions are met before a record saved (the "CancelEvent" action) etc.

Modules.This is where you write your own functions and programs if you want to.
Everything that can be done in a macro can also be done in a module, but you don't get the
Macro interface that prompts you what is needed for each action. Modules are far more
powerful, and are essential if you plan to write code for a multi-user environment, since
macros cannot include error handling. Most serious Access users start out with macros to get a
feel for things, but end up using modules almost exclusively. On the other hand, if your needs
are simple, you may never need to delve into the depths of Access modules.

25) What is meant by sorting and filtering? Explain the ways to filter in Access.

(Refer notes and others)

To find one or more specific records in a form, or to print specific records in a


report, table, or query, you can use a filter. A filter limits a view of data to specific
records without requiring you to alter the design of the underlying query, form, or
report.

Common filters
Several popular filters are available as context menu commands, so that you
don't have to spend time constructing the correct filter criteria. To access these
commands, right-click the field you want to filter.

 NOTE    If you select two or more columns or controls, the filter options will not
be available. If you want to filter the view on multiple columns or controls, you
must either select and filter each column or control separately, or use an
advanced filter option. See the Filter by form and Advanced filters sections in this
article for more information.

Except for OLE Object fields and fields that display calculated values, all field
types offer common filters. The list of filters that are available depends on the
selected field's data type and values.

For example, to see the filters available for the BirthDate field:

On the Home tab, in the Sort & Filter group, click Filter.

Common date filters

To filter for specific values, use the check box list. The list displays all the
values that are currently displayed in the field.
To filter for a range of values, click one of these filters, and specify the required
values.

For example, to see birthdays that fall between the current date and the end of
the year, click Between, and then specify the appropriate start and end dates in
the Between dialog box.

To see all birthdays that fall on a specific date, use the value list. In an unfiltered
view, the value list for each field presents all of the unique values that are stored
in that field.

 NOTE    When a view is filtered, the value list for each field shows only the
unique values that are visible in the view. For example, if the CountryRegion field
is filtered to show only records that have the value USA, the value list of the Full
Name field will show only the names of those who live in the USA. To see more
values in the value list, remove some or all filters from the view.

It is important to note that the values in a date field have an impact on the list of
type-specific filters. If the most recent date value in a date field falls within the
past two years, you see a longer, more detailed filter list. If none of the dates in a
field is less than two years old, you see the shorter filter list.
Long and short common date filter lists

 NOTE    Type-specific filters are not available for Yes/No, OLE object, and
attachments fields. The values list is not available for memo fields, or for fields
that contain rich text.

Filter based on selection

If the value that you want to use as the basis for filtering is currently selected, you
can quickly filter the view by clicking one of the Selection commands. The
commands that are available will vary, depending on the data type of the
selected value. These commands are also available on the context menu of the
field, accessed by right-clicking the field.

For example, if the value 2/21/1967 is currently selected in the BirthDate field, on
the Home tab, in the Sort & Filter group, click Selection to display the filter by
selection commands.
The command list automatically includes the current value, so that you don't have
to type it.

The list of commands also depends on how much of the value is selected. For
example, if you select only some of the characters in the value, you see a
different list of commands, depending on which part of the field you selected.

Filter using the beginning of a field value...

...the middle of a field value...

...or the end of a field value.

 NOTE    Filtering on a partial selection is not available for multivalued fields.

The Selection command is not available for attachments.

Filter by form
This technique is useful when you want to filter on several fields in a form or
datasheet, or if you are trying to find a specific record. Access creates a blank
form or datasheet that is similar to the original form or datasheet, and then allows
you to complete as many of the fields as you want to. When you are done,
Access finds the records that contain the specified values.

 NOTE    You cannot specify field values for multivalued fields using filter by
form, nor for fields with Memo, Hyperlink, Yes/No, or OLE Object data type,
although you can specify values for other fields in the recordset.

For example, if you want to find all Customer records where the contact person's
title is Owner, and that person is located either in Portland or in Eugene, open
the Customers form and, on the Home tab, in the Sort & Filter group, click
Advanced Filter/Sort, and then click Filter by Form.

Enter the first set of values, then click the Or tab, and then enter the next set of
values. Note that if you want a field value to operate as a filter independently of
other field values, you must enter that value on the Look for tab and each Or
tab. Each Or tab represents an alternate set of filter values.

To toggle the filter:  

On the Home tab, in the Sort & Filter group, click Toggle Filter.

Access shows only those records that match your input.

Advanced filters

On occasion, you might want to apply a filter that is not in the common filters list.
For example, if you want to find records that contain dates that occur during the
past seven days or the past six months, you might have to write the filter criterion
yourself.

Using this feature requires that you are familiar with writing expressions.
Expressions are similar to formulas that you write in Excel, and to the criteria that
you specify when designing a query.
For example, if you want to find the names of those contacts whose birthdays
occurred during the past seven days, you can use an advanced filter.

On the Home tab, in the Sort & Filter group, click Advanced and then
click Advanced Filter/Sort on the shortcut menu.

You add the filter fields to the design grid, and specify the filter criteria in the
Criteria row.

When you click Toggle Filter in the Sort & Filter group on the Home tab,
Access displays the filtered records.

Continuing with the same example, if you want to further limit the results to those
whose country/region is USA, switch back to the Filter object tab, add the
CountryRegion field to the grid, and then specify a criterion.

 Top of Page

Apply a filter

Apply a common filter


Apply a filter based on selection
Apply a filter by filling out a form
Apply an advanced filter

 NOTE    If you do not see the filter commands in any of the views, the designer
of the form or database might have disabled filtering. Contact the designer for
further assistance.

Apply a common filter

1. Open a table, query, form, or report in any of the following views:


Datasheet, Form, Report, or Layout.
2. Make sure that the view is not already filtered. On the record selector
bar, verify that either the Unfiltered or the dimmed No Filter icon is
present.

TIP  To remove all the filters for a particular object, on the Home tab, in
the Sort & Filter group, click Advanced, and then click Clear All Filters.

3. Click anywhere in the column or control that corresponds to the first


field that you want to filter.

4. On the Home tab, in the Sort & Filter group, click Filter.

5. Do one of the following:

 To apply a common filter, point to Text (or Number or Date)


Filters, and then click the filter that you want. Filters such as Equals
and Between prompt you to enter the necessary values.

TIP  Certain characters, such as *, %, and ?, have a special meaning


when specified in a filter text box. For example, * represents a string
of characters, so the string a* will match any string that begins with a,
and not only the literal string a*. To disregard the special meaning of
a character, enclose it in square brackets [], like this: a[*]. Databases
that use the ANSI-89 standard treat *, ?, [, ], !, -, and # as special
characters. Databases that use the ANSI-92 standard treat %, _, [, ],
^, and - as special characters. You can use either standard with
Access, but you cannot mix the two standards (e.g., ?a*) in a
particular expression.

 To apply a filter based on field values, clear the check boxes


next to the values on which you do not want to filter, and then click
OK.

Hint  If you have a large list of values, and if you want to filter on one
or only a few of those values, first clear the (Select All) check box
and then select the values you want.
 To filter for null values (a null value indicates the absence of
data) in text, number, and date fields, in the check box list, clear the
(Select All) check box, and then select the check box next to
(Blanks).

6. Repeat the previous three steps for each field that you want to filter.

Apply a filter based on a selection

1. Open a table, query, form, or report in any of the following views:


Datasheet, Form, Report, or Layout.

2. Make sure that the view is not already filtered. On the record selector
bar, verify that either the Unfiltered or the dimmed No Filter icon is
present.

3. Move to the record that contains the value that you want to use as part
of the filter, and then click inside the column (in Datasheet view) or control
(in Form, Report, or Layout view). To filter based a partial selection, select
the characters that you want.

4. On the Home tab, in the Sort & Filter group, click Selection, and then
click the filter you want to apply.

5. To filter other fields based on a selection, repeat the preceding two


steps.

Apply a filter by filling out a form

1. Open a table or query in Datasheet view, or a form in Form view.

2. Make sure the view is not already filtered. On the record selector bar,
verify that either the Unfiltered or the dimmed No Filter icon is present.

3. On the Home tab, in the Sort & Filter group, click Advanced, and
then click Filter by Form on the shortcut menu.
4. Depending on whether you are working in Datasheet view or in Form
view, do one of the following:

 In Datasheet view, click the first row in the column on which


you want to filter. Click the arrow that appears, and select a value.
You can add additional values by clicking the Or tab at the bottom of
the datasheet and selecting another value.

 In Form view, click the arrow that appears in the control, and
select a value on which to filter. You can add additional values by
clicking the Or tab at the bottom of the form and selecting another
value. Click the Or tab to add even more values.

 NOTE    You cannot specify field values for multivalued fields using filter
by form, although you can specify values for any non-multivalued field in
the recordset.

If you do not see a list of field values when you click the drop-down
arrow for a field

 Verify that the data type for the field is not Memo, Hyperlink,
Yes/No, or OLE Object. Fields of these data types cannot be made to
display field values on the Filter By Form object tab. Multivalued
fields similarly cannot display values on the Filter By Form object
tab.

 If the number of records read is more than the number


specified in the Default max records box in the Filter lookup
options for Database section in the Access Options dialog box,
Access doesn't display values for that field on the list. To open the
Access Options dialog box, click the Microsoft Office Button ,
and then click Access Options. Click Editing, then change the
Default max records setting to work around this problem.
 In the Access Options dialog box, click Editing. In the Filter
lookup options for Database section, select the Local indexed
fields and Local nonindexed fields check boxes.

 Switch back to Datasheet view or Form view.

To specify a list of possible values for a field, use the or operator. For
example, you can specify "Portland" or "Oregon" in the City field to filter
for records containing either value.

To filter based on the status of a control, such as a check box or button,


click the control so that it is in the state that you want. To return the
control to a neutral position, so that it won't be used as a criterion for
filtering records, ensure that it is unavailable (appears dimmed).

To filter for records that have null (missing), non-null, blank (empty or ""),
or nonblank values, type Is Null, Is Not Null, "", or Not "" in the field.

5. Sometimes, you might want to specify two alternate sets of criteria. For
example, you might want to see the names of only those contacts whose
CountryRegion value is USA and whose birthdays fall in April, or the
names of only those contacts whose CountryRegion value is Asia and
whose birthdays fall in May.

To retrieve all records that meet any one of multiple sets of criteria, you
need to specify the criteria somewhat differently.

Enter the first set of criteria, then click the Or tab, and then enter the next
set of criteria. Note that if you want a field value to operate as a filter
independently of other field values, you must enter that value on the Look
for tab and each Or tab. In other words, the Look for tab and each Or
tab represents an alternate set of filter values.
Note that each time you add a field criterion to the Or tab, Access creates
another Or tab. This enables you to specify several "or" criteria. The filter
returns any record that contains all of the values specified on the Look
for tab, or all of the values specified on the first Or tab, or all of the values
specified on the second Or tab, and so on.

6. To remove the filter and show all records, click Toggle Filter again.

7. To modify the filter, click Filter By Form again.

The current filter criteria set is displayed.

Apply an advanced filter

1. Open a table, query, form, or report in any of the following views:


Datasheet, Form, Report, or Layout.

2. Make sure that the view is not already filtered. On the record navigator
bar, verify that No Filter appears dimmed (is unavailable). If the record
navigator bar is not visible, click Advanced in the Sort & Filter group on
the Home tab, and then click Clear All Filters (if Clear All Filters
appears dimmed, there are no filters in effect).

3. On the Home tab, in the Sort & Filter group, click Advanced and then
click Advanced Filter/Sort on the shortcut menu.

4. Add the fields on which you want to filter to the grid.

5. In the Criteria row of each field, specify a criterion. The criteria are
applied as a set, and only records that match all of the criteria in the
Criteria row are displayed. To specify alternate criteria for a single field,
type the first criterion in the Criteria row and the second criterion in the
Or row, and so on.

 NOTE    The entire set of criteria in the Or row is applied as an


alternative to the set of criteria in the Criteria row. Any criterion that you
want to be applied for both sets of criteria must be typed in both the
Criteria row and the Or row.

6. Click Toggle Filter to see the filtered rows.

TIP  A good way to learn to write criteria is to apply a common filter or a filter
based on selection that produces a result that is close to what you are looking
for. Then, with the filter applied to the view, display the Filter object tab:

On the Home tab, in the Sort & Filter group, click Advanced and then
click Advanced Filter/Sort on the shortcut menu.

Review the result, and then revise the criteria displayed in the Criteria row to
produce the desired result.

 NOTE    Two special commands are available to you on the Filter document
tab. When you right-click anywhere above the design grid on the tab, the Load
from Query and Save As Query commands are available on the shortcut menu.

The Load from Query command loads the design of a selected query into the
grid. This lets you use the query critieria as filter criteria. The Save As Query
command lets you save the filter settings as a new query.

Vous aimerez peut-être aussi