Introduction To Databases

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 23

1

INTRODUCTION TO DATABASES

In its simplest form, a database is a collection of information that is organized into a list.
Whenever you make a list of information, such as names, addresses, products, or invoices,
you are, in fact, creating database.
A database program lets you:

 Store Information
 Find Information
 Analyze and Print information
 Manage Information
 Share Information

Databases usually consist of several parts. A Microsoft Access database may contain up to six
different database object types. The table on this page identifies the database objects that
you can use when creating Microsoft Access database. Some objects you will use all the time
(such as Tables), others you will hardly use (such as Modules).

Parts of a Microsoft Access Database

Object Description

Table Tables store a database’s data in rows (records) and columns (fields .A
database must always contain at least one table where it can store
information-all the other database objects are optional.

Queries Queries ask a question of data stored in a table.

Forms Forms are custom screens that provide an easy way to enter and view
data in a table or query.

Reports Report present data in table or query in a printed format.

Pages A special type of Web page designed for viewing and working with
Microsoft Access data from an Internet or Internet.

Macros Macros help you perform routine tasks by automating them into a
single command. For example, you could create a macro that
automatically opens and prints a report.

Modules Like macros, Modules automate tasks, but by using a built-in


programming language called Visual Basic or VB. Modules are much
more powerful and complex than macros.
2

UNDERSTANDING THE ACCESS PROGRAM SCREEN

Title bar Menu bar Toolbar

Database
window

Table

Object
bar
Database objects

Element What it’s used for


Title bar Displays the name of the program you are currently using
Status(inbar
this case, Microsoft
Access) and the name of the database you are working on. The title bar appears at
the top of all Windows programs.
Menu Displays a list of menus you use to give commands to Access.
Bar
Toolbar Toolbars are shortcuts-they contain buttons for the most commonly used.
atabase The command center for a database, the Database window allows you to view,
window create, edit, and modify database objects.
Object The Object bar categorizes the different types of database objects. Each type of
Bar database object has its own icon-to view a type of object click its icon on the Object
bar.
Database Database objects are the basic components that make up a database. Database
Objects objects include tables, queries, forms, reports, macros, and modules.
Status Displays message and feedback. The Status bar is especially important in Access,
bar since it can give you meaningful information and messages when you are entering
information into a database.
3

Menus found in Microsoft Access

Menu Description
File File-related commands to open, close, print, and create new files.
Edit Commands to copy, cut, paste, find, and replace text.
View Commands to change how the screen is displayed.
Insert Lists items that you can insert into a database, such as graphics and charts.
Tools Lists tools such the spell checker and macros. You can also change the
default for Microsoft Access options here.
Records Commands to add, delete, sort, and filter information.
Window Commands to display and arrange multiple windows (if you have more than
one file to open.)
Help For assistance or help

USING, HIDING, DISPLAYING AND MOVING TOOLBARS


To display a toolbar
1. Click on the view menu
2. Point toolbars menu item. The list expands to display the various types of toolbars.
3. Any ticked toolbar is displayed on the window.
4. To display a toolbar click on it to tick it.
5. In hiding a toolbar click on it to remove the tick.
Figure 1
KEYSTROKE AND RIGHT MOUSE BUTTON SHORTCUTS

Common Keystroke Shortcuts

Keystroke Description
<Ctrl> + <O> Open a database
<Ctrl> + <W> Close a database
<Ctrl> + <P> Print current view
<Ctrl> + <Z> Undo
<F7> Check spelling
<Ctrl> + <+> New Record
<Ctrl> + <-> Delete record
<Ctrl> + <C> Copies he selected text or object to the Windows clipboard
<Ctrl> + <X> Cuts the selected text or object from its current location to the Windows clipboard
<Ctrl> + <V> Pastes any copied or cut text or object in the Windows clipboard to the current
location
<Ctrl> + <F> Find
<Ctrl> + <H> Find and replace
<Page Down> Next Screen
<Page Up> Previous Screen
4

PLANNING A DATABASE
Planning is the first step in creating a database. You need to decide what you
want the tables to contain and how you want them to be accessed. The main
question to ask yourself is, “What data must be put into the database, to be able
to obtain the information I want?”

Guidelines for creating a good database


 Determine the Purpose of the Database
 Determine the Fields You Need
 Determine the Tables You Need
 Determine the Primary Key
 Determine the Relationship between Tables
 Sketch a Diagram of Your Database

CREATING A DATABASE

a). Using the database wizard.


The easiest way to create a database is with the Database Wizard. The Database
Wizard saves you time and effort by walking you step by step through the process of creating
a database and provides you with ready read-to-use tables, forms, queries, and reports. The
Database Wizard can create databases for contact management, keeping track of inventory,
and taking orders. You can also modify a database created by the Database Wizard to better
suit your needs.

1. Start Microsoft Access by clicking the Windows Start button and selecting
ProgramsMicrosoft Access from the Start menu.
The Microsoft Access Program appears with the Microsoft Access dialog box displayed.
The Microsoft Access dialog box gives you quick access to any database you have
worked on recently and allows you to create a new database.
2. Click the Database Wizard option, click OK, and click the Databases tab if necessary.
The New dialog box appears with the Database tab selected. Here you need to select
the type of database you want to create.
3. Type the name of database you want to create and click Create.
The first screen of the Database Wizard appears and describes the database it will
create for you.
4. Click Next to continue.
The next screen of the Database Wizard appears. This dialog box displays the standard
tables and fields that the Database Wizard is building for you. Click a table on the left
side of the dialog box to view its fields on the right side. If you want, you can add or
remove the standard fields from the database by checking or unchecking them.
5. Click Next to accept the Database Wizard’s standard tables and fields.
Next, you have to decide what your new database should look like. Access provides
you with several aesthetic styles to choose from. Click a style to see a sample for what
it looks like.
5

6. Select the font style that you like best and click next.
Another screen and more aesthetic decisions to make. Here, you need to select the
font you want to use in your reports. You can preview each of the font styles by
clicking them.
7. Select the font style that you like best and click next.
8. Type the title of your database.
This title will appear on the heading of all the reports in your database.
9. Click Finish to create the new database.
10. Explore the tables, forms, and reports in the new database by clicking the various
buttons on the switchboard form.
Move on to the next step when you have seen enough of the new database.
11. Close the new database by selecting FileClose from the menu.

b). Creating a blank database

The advantage of creating a blank database is that it gives you the most flexibility and control
over your database design. The disadvantage of creating a blank database is that you have to
create every table, form, report, and query yourself.
How to create a blank database.

1. Click the New button on the toolbar.


The New dialog box has two tabs:
 General: Blank database that you create from scratch.
 Databases: An assortment of databases which you can create using the
Database Wizard.
2. Select the Blank Database and click OK.
The File New Database dialog box appears. Before can put anything into your new
database you must first give it a file name and save it.

3. Navigate to the drive and folder where you want to save the new database, then
type the name in the File Name box and click Create.

Access creates a new database and saves it using the name you’ve typed. The Database
window appears when it’s finished. If you click the various database object tabs you will
notice that there aren’t any database objects in this database. You will have to create the
entire database yourself.

CREATING DATABASE OBJECTS

You use the Database window to create, open, modify, and manage all the different types of
objects in a database. The Database window contains tabs for each type of database object

1. TABLES

Tables are where a database stores all its information. All the other database objects-queries,
forms, reports, and macros-are merely tools to analyze and manipulate the information
stored in a table. Any of these other database objects are optional-but without tables a
database wouldn’t be a database. Each table in a database stores related information. Most
6

databases have more than one table: each table is used to store a different type of
information.
For example, one table might contain a list of customers and their addresses, while another
table might contain any orders placed by the customers, while yet another table might
contain a list of products.

Tables are made up of groups of fields. A field is a specific type of information, such as a
person’s last name, address or phone number. Together, the related fields for each individual
person, place, or thing make up a single record. If your company has ten employees, your
employee table would have ten records-one for each employee.

Creating a table from scratch.


1) Click the Tables icon in the Objects bar if it is not selected,
2) Then double-click the Create Table in Design View icon.
The new blank table appears in design View. Now all you have to do is add the field you
want included in the table.
3) Type the field name and press tab key
4) On data type column select, the type of data that will be stored in your fields e.g.
date/time, numbers, text, yes/no, currency etc.
5) When through with entering fields save and close the table
6) On the database window, double click on the name of the table to open it(datasheet
view)
7) The table is now ready for you to enter records.

Creating table by entering g data.


1) On the database window double click create table by entering data. A blank table
appears showing column headings called field 1, field 2, filed 3 etc. Note that the rows
are not numbered.
2) Double click on the column heading such as field 1 and when selected delete it and
type the desired heading for this column.
3) Double click on the column heading called field 2and delete it when selected. Then
type the desired heading. Repeat this for all the columns required.

Creating a table using the table wizard

If you’re new to Access, the easiest way to add a table to an existing database is with the
Table Wizard. The Table Wizard asks you a series of questions about what fields you want to
appear in your table and does the dirty work of creating a new table for you. The Table
Wizard can create a variety of different tables to store mailing lists, inventory, catalogs and
more.

1. Make sure that you have a blank database open.


2. Click the Tables icon in the Objects bar if it is not already selected. Access lists all the
tables in the current database.
3. Double-click the Create table using wizard icon.The Table Wizard dialog box appears.
The list to the far left of the dialog box contains the sample tables you can choose from.
4. You start the Table Wizard by selecting the sample table you want to use from the
Sample table list The Table Wizard displays the ready-made fields that you can
7

incorporate into your table in the Sample Fields list. To add a field to your table double-
click the field or select the field and click the button. Click the button to add all the
sample fields to your table.

5. Click Next. The Table Wizard asks you to give your table a name and if you want to have,
Access set a primary key for you.

NOTE: If other tables exist in your database, another screen will appear, asking you how
this table relates to the other tables in your database.
6. Click Finish to create the new table.
The Table Wizard builds the table using the fields you selected and then opens the new
table-ready for your data input.
7. Close the table

Useful Sample Tables from the Table Wizard

Sample Table Description


Employees Tracks such employee data as addresses and phone numbers.
Orders Tracks customer orders.
Contacts A generic table that stores details about your customers and
prospects.
Customers Stores all your customer or client information.
Products Maintains a list of products that your company sells.
Order Details Used with the Orders table-tracks what was purchased in each order
Time Billed Used to keep track of how much time to bill a client.
Expenses Tracks expenses-useful for reimbursements or for billing customers.
Tasks Tracks to-do items.

MODIFYING A TABLE AND UNDERSTANDING DATA TYPES

Once you have created a table, you can modify it later in Design View. Design View allows
you to change the structure of a table by adding, deleting, and modifying its fields.
Because there are so many different types of data, Access offers several different types of
fields. A field’s data type determines the type of information that can be stored in a field.
Data Types lists the various data types available in Access. For example, you cannot enter
text into a number data type field.

Types of data types

Data Type Example Description


Text Legal Name: Stores text, numbers, or a combination of Are the
John Doe most common of all data types.
Memo Notes: Stores long text entries-up to 64,000 characters long
Sally displays a (equivalent to 18 pages of text!) Use memo fields to
high amount of… store notes or anything else that requires lots of
space.
Number Age: 31 Stores numbers that can be used in calculations
8

Date/Time Birthday: Stores dates, time, or both.


April 7, 1969
Currency Price: Stores numbers and symbols that represent money
$8469
AutoNumber Invoice Number: Automatically fills in a unique number for each record.
123 Many tables contain an auto number field that is used
as a primary key.
Yes/No Smoke? Yes or Stores only one of two values, such as Yes
No, True or False,
etc.
OLE Object Photo: Stores objects created in other program such as
graphic, Excel spreadsheet, or Word document
Hyperlink Web Site: Stores click able links to files on your computer or on
www.amazon.co the network or to web pages on the Internet.
m
Lookup Wizard Purpose of Trip: A wizard that helps you create a field whose Values
are selected from a table, query or a present list of
values.

CHANGING A FIELD’S DATA TYPE

a. Open a table in design view


b. First select the field whose data type you want to change.
c. Click the Data Type area
d. A down arrow appears on the right side of the field. Click on this arrow and choose the
data type you want your field to take.

UNDERSTANDING FIELD PROPERTIES

A property is an attribute that defines an object’s appearance, behavior, or characteristics.


For example, a car’s properties would include its color, make and model, and shape. A
property for a numeric field might be the number of decimal places displayed or the
maximum number of characters a field can hold.

Field Properties

Field Property Description

Field Size Text fields: The maximum number of characters (up to 255) that can be entered in
the field. The default setting is 50.

Number/Currency fields: Stores the number as a Byte, Integer, Long Integer,


Single, Double, or Replication ID. The default setting is Long Integer.
Format How the data in the field will be displayed on the screen.
Input Mask Creates a format or pattern in which data musty be entered.
Decimal Places The number of decimal places in number and currency fields.
Caption A label for the field that will appear on forms. If you don’t enter a caption, Access
9

will use the field name as the caption.


Default Value A value that Access enters automatically in the field for new records.
Validation Rule An expression that limits the values that can be entered in the field.
Validation Text The error message that appears when an incorrect or restricted value is entered in a
field with a validation rule.
Required Specify if a value must be entered in the field. The default is No.
Allows Zero Length Specify if the field allows zero length text strings (A string containing no characters).
To enter a zero-length text string type “ “ in the cell. The cell will appear empty.
The default is No.
Indexed Specify if you want to index the field to speed up searches and sorts performed on
the field. The default is No.
Unicode You can offset this increased storage space by compressing the field by setting the
Unicode Compression property to Yes.

ADDING A PRIMARY KEY TO A TABLE

A primary key is a special kind of indexed field that uniquely identifies each record in a table.
When you think about primary key fields think unique-each primary key value must be the
only one of its kind in a table. E.g. a customer ID or invoice number would be two good
examples of fields that could be used as a table used as a table’s primary key.
Here are some things you need to know about primary keys:
 A table can only have one primary key.
 The values in the primary key fields must be unique. AutoNumber fields automatically
add a new, unique number to each record in a table.
 Every table you create should have a primary key because it helps keep your data
organized and easy to work with.
 Yes/No, OLE, and hyperlink fields can’t be used as the primary key.
 The primary key is normally a single field, but two or more fields can act together as
the primary key, so long as their combined values are unique.
 Primary keys are especially important in creating relationships between tables.

To add a primary key to a table then make sure it is in design view. Select the fields you want
to use as a primary key then on edit menu click primary key or Click the Primary Key button
on the toolbar. A picture of a key appears at the beginning of the row. Now save the changes
made.

INSERTING, DELETING, AND REORDERING FIELDS

You can insert, delete, and reorder fields in your tables in Design view. Remember that in
Design view for tables, each row corresponds to a field. You add a field by inserting a new
row and delete a field by deleting its corresponding row by selecting on a row then insert
using insert menu or delete using edit menu.

SETTING A DEFAULT VALUE

You can enter a Default Value to specify a value that is automatically entered in a field when a
new record is created. For example, if most of your clients are from Texas, you could set the
10

default value for the State field to “TX”. When a user adds a record to the table, they can
either accept the TX default value for the State field or enter their own value.

To enter a default value


 Open the table in design view.
 Select the field you want to set its default value.
 On field properties section click on default value. Now type the value you want to
use as default value.
11

VALIDATING DATA

Without a doubt, data validation is thee most powerful tool you can use to prevent data entry
errors. With data validation, Access actually tests data to make sure that it conforms to what
you want to appear in the table. If the incoming data doesn’t meet your requirements,
Access kicks it out and displays an error message.

Data validation works best in number, currency, and date/time fields. You can create a
validation rule for text entries, but doing so can be complicated-especially if you want to test
a lot of text variables.

There are actually two boxes that relate to data validation. They are the:
 Validation Rule box: Use to specify the requirements for data entered into the field.
 Validation Text box: When data is entered that violates the validation rule you can
use the Validation Text box to specify the message to be modify and use in your table.

Creating data validation rules can be a little tricky-you create a data validation using the same
hard-to-remember operators that you use in filters and queries. Table 4-7: Data Validation
Examples contains some data validation that you can modify and use in your tables.
Consider the following table. It contains samples of the most common types of validation
rules. Feel free to copy, modify, or mix and match these examples to create your own
validation rules.

Data Validation Examples

Validation Rule Description


<100 Must be less than 100
<=100 Must be equal to or less than 100
Between 1 and 10 Must between 1 and 10
<>0 Must not equal 0
<1/1/95 Must be a date before 1/1/95
>=Date ( ) Must be today’s date or later
<=Date ( ) Must be today’s date or earlier
“Business” Or “Pleasure” Or “Other” Must be Business or Pleasure or Other
Like “??” Must have 2 characters
Like “###” Must have 4 numbers

CREATING AN INPUT MASK

An Input Mask limits the amount and type of information that can be entered in a field.
There are two ways to create an input mask:

 Click the Build button and have the Input Mask Wizard create the input mask for you
(the fast and easy way). The only problem with the Input Mask Wizard is that it can
only help you create input masks for phone numbers, Social Security numbers, zip
codes, and date and time fields.
12

 Create the input mask yourself by typing a series of characters in the Input Mask box
(the hard way). If you want to use this brutal method refer to Table 4-8: Input Mask
Characters to see what you have to enter to create an input mask.

Creating an input mask by hand is difficult but it can be done. You need to create the input
mask by entering the characters shown in the following table in the Input Mask box.

Input Mask Characters

Character Description
0 Numbers 0 to 9 required; plus and minus signs not allowed
9 Number or space optional plus and minus signs not allowed
# Number or space optional plus and minus signs not allowed
.,:;-/ Decimal point, thousands, date, and time separators
A Letter or number Required
A Letter or number optional
L Letters A to Z required
? Letter or number optional
& Character or space required
C Character or space optional
< Converts the following characters to lowercase
> Converts the following characters to uppercase
! Displays characters from right to left, rather than Left to right
\ Displays the following input mask character. For Example, \* would display
*
Password Displays an asterisk (*) for Each character you type

CREATING A LOOKUP FIELD/ VALUE LIST

Lookup fields are defiantly one of the coolest and most powerful features in Access. A lookup
field lets you pick a field’s entry from a list of values. Similar to its cousin the lookup list, a
value list displays list of values in a drop-down list. Unlike a lookup list, which displays data in
a table or query, a value list displays a list of options that you manually enter. A value list is
useful if you enter the same data in a field repeatedly. There are two ways that a lookup field
can get its list of values:

 From a list of values or options that you enter yourself. For example you could add the
values FedEx, UPS, and Airborne to a field.

 From a list of values in a table or query. For example, instead of entering a


CustomerID from a list of names.

To create a lookup field


 Your table should be in design view.
 Click on insert menu then look up field. A lookup wizard dialog box appears. Select
whether you want to get values from the table/ query or you want to create on your
own.
13

 Click next and follow the instruction on the wizard.

RELATIONSHIP

An association established between common fields (columns) in two tables. A relationship can
be one-to-one, one-to-many, or many-to-many.

In a relational database, relationships enable you to prevent redundant data. For example, if
you are designing a database that will track information about books you might have a table
called titles that stores information about each book, such as the book’s title, date of
publication, and publisher. There is also information you might want to store about the
publisher, such as the publisher's phone number, address, and zip code. If you were to store
all of this information in the titles table, the publisher’s phone number would be duplicated for
each title that the publisher prints.

A better solution is to store the publisher information only once in a separate table, publishers.
You would then put a pointer in the titles table that references an entry in the publisher table.

To make sure your data is not out of sync; you can enforce referential integrity between the
titles and publishers tables. Referential integrity relationships help to ensure information in one
table matches information in another. For example, each title in the titles table must be
associated with a specific publisher in the publisher’s table. A title cannot be added to the
database for a publisher that does not exist in the database.

How Do Relationships Work?


A relationship between tables works by matching data in key fields. These key fields
usually have the same name in the two tables. For example, both the Customer table and
the Orders table have a Customer ID field.

Records in the Orders table that have the same Customer ID as a record in the Customer
table would be orders placed by that customer.

Benefits of Relationships
You will see many benefits by linking the tables in your database before you begin creating
forms, reports and queries.

 Data Integrity:-Relationships will not allow creating records in a secondary table


unless there is a matching record in the master table. For example, an order could not
be placed in the order table for a non-existent customer.
 Optimal Performance: - When running reports and queries, having relationships
established assures optimal performance.
 Ease of Use in Designing Systems:- If the relationships have been
established then it will be much faster and easier to design the forms, reports and
queries needed in the database.
14

Defining Table Relationships


A relationship works by matching data in key columns — usually columns with the same name
in both tables. In most cases, the relationship matches the primary key from one table, which
provides a unique identifier for each row, with an entry in the foreign key in the other table.
For example, sales can be associated with the specific titles sold by creating a relationship
between the title_id column in the titles table (the primary key) and the title_id column in the
sales table (the foreign key). There are three types of relationships between tables.
 One-to-Many Relationships
 Many-to-Many Relationships
 One-to-One Relationships

One-to-Many Relationships
A one-to-many relationship is the most common type of relationship. In this type of
relationship, a row in table A can have many matching rows in table B, but a row in table B
can have only one matching row in table A. For example, the publishers and titles tables have a
one-to-many relationship: each publisher produces many titles, but each title comes from
only one publisher.
A one-to-many relationship is created if only one of the related columns is a primary key or
has a unique constraint.

Many-to-Many Relationships
In a many-to-many relationship, a row in table A can have many matching rows in table B, and
vice versa. Example is a relationship between distributors and products. i.e. one distributor
distributes many products and one product can be distributed by many distributors.

One-to-One Relationships
In a one-to-one relationship, a record in a table specifically relates to one record in another
table i.e. A can have no more than one matching row in table B, and vice versa. A one-to-one
relationship is created if both of the related columns are primary keys or have unique
constraints.
This type of relationship is not common because most information related in this way would
be all in one table. You might use a one-to-one relationship to:

 Divide a table with many columns.

 Isolate part of a table for security reasons.

 Store data that is short-lived and could be easily deleted by simply deleting the table.

Enforcing Referential Integrity


Referential integrity is a system of rules that ensure relationships between rows in related
tables are valid and that you don't accidentally delete or change related data.
When referential integrity is enforced, you must observe the following rules:

 You can't enter a value in the foreign key column of the related table if that value
doesn't exist in the primary key of the related table. However, you can enter a null in
the foreign key column. For example, you can't indicate that a job is assigned to an
15

employee who isn’t included in the employee table, but you can indicate that an
employee has no assigned job by entering a null in the job_id column of the employee
table.

 You can't delete a row from a primary key table if rows matching it exist in a related
table. For example, you can't delete a row from the jobs table if there are employees
assigned to the job represented by that row in the employee table.

 You can't change a primary key value in the primary key table if that row has related
rows. For example, you can't delete an employee from the employee table if that
employee is assigned to a job in the jobs table.

You can set referential integrity when all of the following conditions are met:
 The matching column from the primary table is a primary key.
 The related columns have the same data type and size.
 Both tables belong to the same database.

Creating a Relationship Between Tables


You create a relationship between two tables when you want them to share data. You can
store data in one of the tables, but make it available to both. You can also create a
relationship to enforce referential integrity between related tables.
Before you create a relationship, you must first define a primary key in at least one of the
tables. You then relate the primary key columns to matching columns in another table. Once
you create the relationship, those matching columns become the foreign key of the related
table.

To create a relationship between tables


1. In your database diagram, click the row selector for the database column or
combination of columns that you want to relate to a column in another table.
2. While the pointer is positioned over the row selector, drag the pointer to the related
table. To relate the selected columns to the primary key of the related table, drag the
pointer to the related table’s title bar.
3. Release the mouse button. The Create Relationship dialog box appears and attempts
to match the columns you selected with columns of the same name and data type in
the related table.
4. In the Create Relationship dialog box, confirm that the columns you want to relate are
shown in the Primary key table and foreign key table lists.
5. Choose OK to create the relationship.
The primary key side of the relationship is denoted by a key symbol. In one-to-one
relationships, the table that initiated the relationship determines the primary key side. For
example, if you create a relationship from the pub_id column in the publishers’ table to the
pub_id column in the pub_ info table, then the publishers’ table is on the primary key side of the
relationship.
The foreign key side of a relationship is denoted by a key symbol for a one-to-one relationship
or an infinity symbol for a one-to-many relationship.
16

Tip If you want to see labels for relationship lines, use the Show Relationship Labels
command.

Sorting information in a table


1. In Datasheet view, click the field you want to use for sorting records. To sort records in
a subform, click the field you want to sort.
2. Do one of the following:
o To sort in ascending order, click Sort Ascending.
o To sort in descending order, click Sort Descending.

Filtering records in a table


There are various type of filters:
Filter records by selecting values in a datasheet
1. In a field datasheet, or subdatasheet, find one instance of the value you want records
to contain in order to be included in the filter's results.
2. Select the value, and then click Filter by Selection on the toolbar. How you select the
value determines what records the filter returns. For more information on selecting

values, click .
Repeat step 2 until you have the set of records you want.

Add a field (column) to a table in Datasheet view

1. Open the table in datasheet view.

2. Click in the column to the right of where you want to insert a new column, and then
on the Insert menu, click Column.

3. Double-click the new column's name and then type a name for the column If you want
to customize a field's definition further — for example, to change its data type, or
define a validation rule, use table Design view.

Freeze and unfreeze columns in Datasheet view


You can freeze one or more of the columns on a datasheet so that they become the leftmost
columns and are visible at all times no matter where you scroll.
1. Open a table, query, form, view, or stored procedure in Datasheet view.
2. Select the columns you want to freeze.
To select the column, click the field selector for that column.
To select more than one of the column, click the column field selector and then,
without releasing the mouse button, drag to extend the selection.
3. To freeze the selected columns, click Freeze Columns on the Format menu.
To unfreeze all columns, click Unfreeze All Columns on the Format menu.
Show hidden columns in Datasheet view

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


17

2. Click Unhide Columns on the Format menu.

3. In the Unhide Columns dialog box, select the names of the columns that you want to
show.

2. CREATING A QUERY
You can create a query using different ways like
 Using the design view
 Using the wizard.

Creating a query in design view.


 On database window click on query object
 Click on design button or double click create query in design view.
 A show table dialogue box pops up listing the existing tables on you database.
 Select or highlight on the table you want and click ADD command button. A
table listing its field is copied to select query dialogue box.
Note: if you want to use a query click using a query click on Query tab on show
table dialogue box. To use both i.e. query and table click on both tab.
 When through with selection of the tables of query click on Close command
button.
 On select query dialogue box drag the fields you want and drop them at a row
labeled field. On sort row select the sort format you want (optional).
 Type the criteria you want to use to display your records.
 Save your query then run it to view the records.

Creating a query using the wizard.


Double click on create query using the wizard. Follow the instruction on the wizard.

Common Criteria Operators

Operator Example Description

= = “MN” Finds records equal to MN

<> <> “MN” Finds records not equal to MN

< <10 Finds records less than 10

<= <=10 Finds records less than or equal to 10

> >10 Finds records greater than 10

>= >=10 AND <>5 Finds records greater than or equal to


10

BETWEEN BETWEEN 1/1/99 AND 12/31/99Finds records between 1/1/99 AND


18

12/31/99

LIKE LIKE “S*” Finds text beginning with the letter


You can use LIKE with wildcards such as *

3. CREATING A FORM
You can create a form by
 Using the Auto form
 Using a wizard
 Creating a form in design view.

Using auto form


With AutoForm, you select one record source and either columnar, tabular, or datasheet
layout; AutoForm creates a form that uses all the fields from the record source you selected
and all the fields from its related record sources.

1. In the Database window, click Forms under Objects.

2. Click the New button on the Database window toolbar.

3. In the New Form dialog box, click one of the following wizards:
o AutoForm: Columnar Each field appears on a separate line with a label to its
left.

o AutoForm: Tabular The fields in each record appear on one line, with the
labels displayed once at the top of the form.

o AutoForm: Datasheet The fields in each record appear in row-and-column


format, with one record in each row and one field in each column. The field
names appear at the top of each column.
4. Click the table or query that contains the data you want to base your form on.

5. Click OK.

Create a form with a wizard

1. In the Database window, click Forms under Objects.

2. Click the New button on the Database window toolbar.

3. In the New Form dialog box, click the wizard that you want to use. A description of the
wizard appears in the left side of the dialog box.
19

4. Click the name of the table or other record source that includes the data you want to
base your form on.

Note You don't need to do this step if you click the Form Wizard option — you can
specify the record source for the form in the wizard.

5. Click OK.

6. If you clicked Form Wizard, Chart Wizard, or PivotTable Wizard in step 3, follow the
directions in the wizard dialog boxes.

Create a blank form in design view

1. In the Database window, click Forms under Objects.

2. Click the New button on the Database window toolbar.

3. In the New Form dialog box, click Design View.

4. Click the name of the table or other record source that includes the data you want to
base your form on. If the form won't contain data (for example, if you want to create a
form to use as a switchboard to open other forms or reports, or if you want to create a
custom dialog box), don't select anything from this list.

Note If you want to create a form that uses data from more than one table, base
your form on a query.

5. Click OK.
6. on the field list listbox drag the fields you want and drop them on the form.
7. arrange you fields in the best way you like then save your form and run it to display
the record you’ve entered or to enable you to enter the records on the table.

Add or remove a form header and footer or a page header and footer

1. Open the form in Design view.

2. Click Form Header/Footer or Page Header/Footer on the View menu.

Notes

 Form headers and footers appear at the top and bottom of a form in Form view and at
the beginning and end of a printed form. Page headers and footers appear at the top
and bottom of each printed page — they don't appear in Form view.

 If you remove a header and footer, Microsoft Access deletes the controls in the
header and footer.

 You can only add a header and footer as a pair. If you don't want both a header and a
footer, you can size the one you don't want so that it has no height, or you can set its
Visible property to No. You can also set the Display When property of a form header
20

and footer to specify when you want the header and footer to be displayed ? always,
in print only, or on the screen only.

Subforms: What they are and how they work


A subform is a form within a form. The primary form is called the main form, and the form
within the form is called the subform. A form/subform combination is often referred to as a
hierarchical form, a master/detail form, or a parent/child form.
Subforms are especially effective when you want to show data from tables or queries with a
one-to-many relationship. For example, you could create a form with a subform to show data
from a Categories table and a Products table.
The data in the Categories table is the "one" side of the relationship. The data in the Products
table is the "many" side of the relationship — each category can have more than one product.
Create a form and a sub form at the same time
Before using this procedure, make sure you've set up your table relationships correctly.

1. In the Database window, click Forms under Objects.

2. Click the New button on the Database window toolbar.

3. In the New Form dialog box, double-click Form Wizard in the list.

4. In the first wizard dialog box, select a table or query from the list. For example, to
create a Categories form that displays products for each category in a sub form, select
the Categories table (the "one" side of the one-to-many relationship).

5. Double-click the fields you want to include from this table or query.

6. In the same wizard dialog box, select another table or query from the list. Using the
same example, select the Products table (the "many" side of the one-to-many
relationship in the Categories form example).

Note It doesn't matter which table or query you choose first.

7. Double-click the fields you want to include from this table or query.

8. When you click Next, if you set up the relationships correctly before starting the
wizard, the wizard asks which table or query you want to view by. Using the same
example, to create the Categories form, click By Categories.

9. In the same wizard dialog box, select the Form with Sub form(s) option.

10. Follow the directions in the remaining wizard dialog boxes. When you click Finish,
Microsoft Access creates two forms, one for the main form and subform control, and
one for the sub form.
21

4. Create a report
You can create a report by
 Create a report by using Auto Report. With Auto Report, you select one record source
and either columnar or tabular layout; Auto Report uses all the fields from the record
source and applies the last auto format you used to the report.
 Create a report with a wizard. The wizard asks you detailed questions about the
record sources, fields, layout, and format you want and creates a report based on your
answers.
 Create a report in design view

Create a report using Auto Report


Auto Report creates a report that displays all fields and records in the underlying table or
query.

1. In the Database window, click Reports under Objects.

2. Click the New button on the Database window toolbar.

3. In the New Report dialog box, click one of the following wizards:
o AutoReport: Columnar. Each field appears on a separate line with a label to its
left.

o AutoReport: Tabular. The fields in each record appear on one line, and the
labels print once at the top of each page.
4. Click the table or query that contains the data you want to base your report on.

5. Click OK.

Create a report with a wizard

1. In the Database window, click Reports under Objects.

2. Click the New button on the Database window toolbar.

3. In the New Report dialog box, click the wizard that you want to use. A description of
the wizard appears in the left side of the dialog box.

4. Click the table or query that contains the data you want to base your report on.

Note Microsoft Access uses this table or query as the default record source for the
report. However, you can change the record source in the wizard and select fields
from other tables and queries.

5. Click OK.
22

6. If you clicked Report Wizard, Chart Wizard, or Label Wizard in step 3, follow the
directions in the wizard dialog boxes. If you click AutoReport: Tabular or AutoReport:
Columnar, Microsoft Access automatically creates your report.

If the resulting report doesn't look the way you want, you can change it in Design
view.

Create a blank report and select a record source

1. In the Database window, click Reports under Objects.

2. Click the New button on the Database window toolbar.

3. In the New Report dialog box, click Design View.

4. Click the name of the table or query that contains the data you want to base your
report on. (If you want an unbound report, don't select anything from this list.)

Tip If you want to create a report that uses data from more than one table, base your
report on a query.

5. Click OK.
6. On the field list box drag the fields that you want and drop them on the report design
view.

Add or remove a report header and footer or a page header and footer

1. Open the report in Design view.

2. Click Report Header/Footer or Page Header/Footer on the View menu.

Notes

 You can add a header and footer only as a pair. If you don't want both a header and
footer, set the visible property to No for the section you don't want. Or remove all
controls from the section, and then size the section to zero height or set its Height
property to 0.

 If you remove a header and footer, Microsoft Access also removes the controls in the
header and footer.

Make text in a text box or other control bold, italic, or underlined

1. Open a form in Design view, a report in Design view,

2. Click the control that contains the text you want to change.

3. On the Form/Report Formatting toolbar, click Bold to make the text bold, Italic to
make the text italic, or Underline to make the text underlined.
23

You might also like