You are on page 1of 14

Assignment Access

1.How to create a Table


A. Creating a Table by Using the Table Wizard
- Microsoft Access has a wizard named the Table Wizard
that will create a table for.This wizard gives you
suggestions about what type of table you can create
(for example, a Mailing List table, a Students table, a
Tasks table, and so on) and gives you many different
possible names for fields within these tables. To use the
Table Wizard to create a table, follow these steps:
1. Create a new, blank database.
2 .In the Database window, click Tables under Objects,
and then click New.
3. In the New Table dialog box, double-click Table
Wizard.
4. Follow the directions in the Table Wizard pages.
5. If you want to modify the table that the Table Wizard
creates, open the table in Design view when you have
finished using the Table Wizard.
B. Creating a Table by Entering Data in a Datasheet
In Microsoft Access, you can also create a table by just
entering data into columns (fields) in a datasheet. If
you enter data that is consistent in each column (for
example, only names in one column, or only numbers in
another column), Access will automatically assign a

data type to the fields. To create a table by just


entering data in a datasheet, follow these steps:
1. Create a new, blank database.
2. In the Database window, click Tables under
Objects, and then click New.
3. In the New Table dialog box, double-click Datasheet
View. A blank datasheet is displayed with default
column names Field1, Field2, and so on.
4. Rename each column that you want to use. To do
so, double-click the column name, type a name for
the column, and then press ENTER.
You can insert additional columns at any time. To do so,
click in the column to the right of where you want to
insert a new column, and then on the Insert menu, click
Column. Rename the column as described earlier.
5. Enter your data in the datasheet. Enter each kind
of data in its own column. For example, if you are
entering names, enter the first name in its own
column and the last name in a separate column. If
you are entering dates, times, or numbers, enter
them in a consistent format. If you enter data in a
consistent manner, Microsoft Access can create an
appropriate data type and display format for the
column. For example, for a column in which you
enter only names, Access will assign the Text data
type; for a column in which you enter only
numbers, Access will assign a Number data type.
Any columns that you leave empty will be deleted
when you save the datasheet.
6. When you have added data to all the columns that
you want to use, click Save on the File menu.

Microsoft Access asks you if you want to create a


primary key. If you have not entered data that can be
used to uniquely identify each row in your table, such
as part numbers or an ID numbers, it is recommended
that you click Yes. If you have entered data that can
uniquely identify each row, click No, and then specify
the field that contains that data as your primary key in
Design view after the table has been saved. To define a
field as your primary key after the table has been
saved, follow these steps:
1. Open the table that Access created from the data
that you entered in datasheet in Design view.
2. Select the field or fields that you want to define as
the primary key.

3. To select one field, click the row selector for the


desired field.

4. To select multiple fields, hold down the CTRL key,


and then click the row selector for each field.
5. On the Edit menu, click Primary Key.

6. If you want the order of the fields in a multiple-field


primary key to be different from the order of those
fields in the table, click Indexes on the toolbar to
display the Indexes window, and then reorder the
field names for the index named PrimaryKey.
7. As mentioned earlier, Microsoft Access will assign
data types to each field (column) based on the kind

of data that you entered. If you want to customize


a field's definition further--for example, to change a
data type that Access automatically assigned, or to
define a validation rule--open the table in Design
view.

C. Creating a Table in Design View


If you want to create the basic table structure yourself
and define all the field names and data types, you can
create the table in Design view. To do so, follow these
steps:
1. Create a new, blank database.
2. In the Database window, click Tables under
Objects, and then click New.
3. In the New Table dialog box, double-click Design
View.
4. In the <Table Name>: Table dialog box, define
each of the fields that you want to include in your
table. To do so, follow these steps:
5. Click in the Field Name column, and then type a
unique name for the field.
6. In the Data Type column, accept the default data
type of Text that Access assigns or click in the Data
Type column, click the arrow, and then select the
data type that you want.
7. In the Description column, type a description of the
information that this field will contain. This
description is displayed on the status bar when you
are adding data to the field, and it is included in
the Object Definition of the table. The description is
optional.

8. Once you have added some fields, you may need


to insert a field between two other fields. To do so,
click in the row below where you want to add the
new field, and then on the Insert menu, click Rows.
This creates a blank row in which you can add a
new field.

9. To add a field to the end of the table, click in the


first blank row.
After you have added all the fields, define a primary
key field before saving your table. A primary key is one
or more fields whose value or values uniquely identify
each record in a table. To define a primary key, follow
these steps:
1. Select the field or fields that you want to define as
the primary key.

2. To select one field, click the row selector for the


desired field.

3. To select multiple fields, hold down the CTRL key,


and then click the row selector for each field.
4. On the Edit menu, click Primary Key.
5. If you want the order of the fields in a multiple-field
primary key to be different from the order of those
fields in the table, click Indexes on the toolbar to
display the Indexes dialog box, and then reorder
the field names for the index named PrimaryKey.

You do not have to define a primary key, but it is


usually a good idea. If you do not define a primary key,
Microsoft Access asks if you want Access to create one
for you when you save the table.
6. When you are ready to save your table, on the File
menu, click
Save, and then type a unique name for the table.

2. How to create a Query


-First, you will use a wizard to create the query,
based on the sample table that you just created.
Then, you will enhance the query in Design view. At
each step, you can review the SQL statement that
is automatically generated by the steps that you
take.

1. On the Create tab, in the Other group,


click Query Wizard.
1. In the New Query dialog box, click Simple Query
Wizard, and then click OK.
2. Under Tables/Queries, click the table that has the
data that you want to use. In this case, click Table:
Customers. Note that a query can also use
another query as a recordsource.
3. Under Available Fields, double-click
the Contact, Address, Phone, and City fields.

This adds them to theSelected Fields list. When


you have added all four fields, click Next.
4. Name the query London Contacts, and then
click Finish.
Access displays all of the contact records in
Datasheet view. The results show all of the records,
but show only the four fields that you specified in
the query wizard.
Review the initial SQL statement
Click SQL View on the Access status bar; or, rightclick the query object tab, and then click SQL
View. Access opens the query in SQL view, and
displays the following:
SELECT Customers.[Contact], Customers.[Address],
Customers.[Phone], Customers.[City]
FROM Customers;
As you can see, in SQL the query has two basic
parts: the SELECT clause, which lists the fields that
are included in the query, and the FROM clause,
which lists the tables that contain those fields.
NOTE If you added the fields in a different order
from the preceding procedure, the order that you
used will be reflected in the SELECT clause.
5. Close the query, and note that your query is
automatically saved.
3.How to create Form
A. Create a blank form
1. To create a form with no controls or preformatted
elements: On the Create tab, click Blank Form.
Access opens a blank form in Layout view, and
displays the Field List pane.

2. In the Field List pane, click the plus sign (+) next
to the table or tables that contain the fields that
you want to see on the form.
3. To add a field to the form, double-click it or drag it
onto the form. To add several fields at once, hold
down CTRL and click several fields, and then drag
them onto the form at the same time.
NOTE The order of the tables in the Field List pane
can change, depending on which part of the form is
currently selected. If you are not able to add a field to
the form, try selecting a different part of the form and
then try adding the field again.
1. Use the tools in the Controls group on the Form
Layout Tools tab to add a logo, title, page
numbers, or the date and time to the form.
2. If you want to add a wider variety of controls to the
form, click Design and use the tools in
the Controlsgroup.

B. Create a split form


A split form gives you two views of the data at the same time a Form view and a
Datasheet view. Working with split forms gives you the benefits of both types of
forms in a single form. For example, you can use the datasheet portion of the form to
quickly locate a record, and then use the form portion to view or edit the record. The
two views are connected to the same data source and are synchronized with each
other at all times.

To create a new split form by using the Split Form tool, in the Navigation Pane, click
the table or query that contains the data, and then on the Create tab, click More
Forms, and then click Split Form.
Access creates the form and you can make design changes to the form. For example,
you can adjust the size of the text boxes to fit the data, if necessary. For more
information on working with a split form, see the article on creating a split form.

C. Create a form that displays multiple records


A multiple item form, also known as a continuous form,
and is useful if you want a form that displays multiple
records but is more customizable than a datasheet, you
can use the Multiple Items tool.
1. In the Navigation Pane, click the table or query that
contains the data you want to see on your form.
2. On the Create tab and click More
Forms > Multiple Items.
Access creates the form and displays it in Layout view.
In Layout view, you can make design changes to the
form while it is displaying data. For example, you can
adjust the size of the text boxes to fit the data.
D. Create a form that contains a subform

When you are working with related data that is stored


in separate tables, you often need to view data from
multiple tables or queries on the same form and
subforms are a convenient way to do this. Since there
are several ways of adding a subform depending on
your needs.
E. Create a Navigation form
A navigation form is simply a form that contains a
Navigation Control. Navigation forms are a great
addition to any database, but creating a navigation
form is particularly important if you plan to publish a
database to the Web, because the Access Navigation
Pane does not display in a browser.
1. Open the database to which you want to add a
navigation form.
2. On the Create tab, in the Forms group,
click Navigation, and then select the style of
navigation form that you want.
Access creates the form, adds the Navigation Control to
it, and displays the form in Layout view.
4. How to create a Report
a. Create a report by using the Report tool

The Report tool provides the fastest way for you to


create a report, because it generates a report
immediately without prompting you for information.
The report displays all the fields from the underlying
table or query. The Report tool may not create the

final, polished product that you ultimately want, but


it is quite useful as a means to quickly look at the
underlying data. You can then save the report and
modify it in Layout view or Design view so that it
better serves your purposes.

1. In the Navigation Pane, click the table or query on


which you want to base the report.

2. On the Create tab, in the Reports group, click


Report. Button image

3. Access builds the report and displays it in Layout


view.
After viewing the report, you can save it and then
close both the report and the underlying table or
query that you used as a record source. The next
time that you open the report, Access will display
the most recent data from your record source.
b. Create a report by using the Report Wizard
-You can use the Report Wizard to be more
selective about what fields appear on your report.
You can also specify how the data is grouped and
sorted, and you can use fields from more than one
table or query, provided you have specified the
relationships between the tables and queries
beforehand. Find links to more information about
creating relationships in the See Also section.

1. On the Create tab, in the Reports group,


click Report Wizard.
2. Follow the directions on the Report Wizard pages.
On the last page, click Finish.
When you preview the report, you see the report as
it will appear in print. You can also increase the
magnification to zoom in on details.
C. Create labels by using the Label Wizard
-Use the Label Wizard to easily create labels for a
wide variety of standard label sizes.
1. In the Navigation Pane, open the table or query
that will be the record source for your labels by
double-clicking it.
2. On the Create tab, in the Reports group,
click Labels.
3. Follow the directions on the pages of the Label
Wizard. On the last page, click Finish.
Access displays your labels in Print Preview so that
you can see them as they will appear when they
are printed. You can use the slider control on the
Access status bar to zoom in on details.

5. How to Create a Relationship


A relationship helps you combine data from two different tables. In an
Access desktop database, you can create a relationship in
the Relationships window. Creating a relationship in an Access app is a
different process, as explained later under Create a relationship in an
Access app.
1. On the Database Tools tab, in the Relationships group,
click Relationships.

1. If you haven't yet defined any relationships, the Show Table dialog box
automatically appears. If it doesn't appear, on the Design tab, in
the Relationships group, click Show Table.
The Show Table dialog box displays all of the tables and queries in the
database. To see only tables, click Tables.
1. Select one or more tables, and then click Add. After you have finished
adding tables, click Close.
2. Drag a field (typically the primary key) from one table to the common field
(the foreign key) in the other table. To drag multiple fields, press the Ctrl
key, click each field, and then drag them.
The Edit Relationships dialog box appears.

1. Verify that the field names shown are the common fields for the
relationship. If a field name is incorrect, click on the field name and select
the appropriate field from the list.
2. To enforce referential integrity for this relationship, select the Enforce
Referential Integrity box.
3. Click Create.
Access draws a relationship line between the two tables. If you selected
the Enforce Referential Integrity check box, the line appears thicker at
each end. In addition, again only if you selected the Enforce Referential
Integritycheck box, the number 1 appears over the thick portion on one

side of the relationship line, and the infinity symbol () appears over the
thick portion on the on the other side of the line.
NOTES

To create a one-to-one relationship Both of the common fields


(typically the primary key and foreign key fields) must have a unique
index. This means that the Indexed property for these fields should be set
to Yes(No Duplicates). If both fields have a unique index, Access creates
a one-to-one relationship.

To create a one-to-many relationship The field on the one side


(typically the primary key) of the relationship must have a unique index.
This means that the Indexed property for this field should be set
to Yes(No Duplicates). The field on the many side should not have a
unique index. It can have an index, but it must allow duplicates. This
means that the Indexed property for this field should be set to
either No or Yes (Duplicates OK). When one field has a unique index,
and the other does not, Access creates a one-to-many relationship.