Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
sec2_second_term_2013_doc.doc
Скачиваний:
0
Добавлен:
01.07.2025
Размер:
1.84 Mб
Скачать

Total Queries:

Exercise 10:

Design a Query named as (s1) to display the department name and the number of

the employees working in it.

Make a Query to display the department name and the name of the employee.

T o make this Query (totalized), click on the

A lternatively, from (shortcut menu), click on any place in the foot area of (design)

- (Design) window appears as follows:

When we put 'Group by' under department name, it means (totalizing) according

to each department. As for (Count) when we put it under the employee's name, it

means the number of the employees for each department.

Task:

Design a Query named as (S2) to display the project name and the number of the

employees who work in it.

Questions

  1. Explain briefly the following queries?

Select Query

Update Query

Append Query

  1. What is the difference between the select Query and the action Query?

3- Put () in front of the correct statement and (x) in front of the wrong one.

a) The calculated field by query is saved inside the table ( )

b) Data can be saved inside queries ( )

c) Inserting and modifying data in tables can be through queries ( )

Chapter Seven Forms

The form is considered a type of database entities. It is used basically for data

entry or displays it in a database. You can also use the form to open other forms

and reports in the database or as a custom (dialogue box) that accepts the user's

entry and implement an order as shown in the following figure:

Form types

We can determine the types of forms as follows:

1. Display forms - Entry forms.

2. Main switchboard list forms.

3. Dialogue box forms.

Form Properties:

1. The form retrieves and displays its data from the basic record source (Query,

Table).

- In (Form design), we can store information about the form such as (The form title

and page number).

2. The graphic elements are stored in (Form Design) such as (lines and squares).

3. The account comes from (expression Stored in Form Design).

4. You can create a link between the form and the source of its records using

(Control Tools). The most common elements are(Text boxes)

The following figure shows data as a source for (Form Record, Graphics,

Expressions, and Titles) as stored elements in (Form Design).

Creating a Form:-

There are many ways to create (Forms) and we will handle the following:

1- Creating forms using (Form Wizard)

According to your answers, the Wizard will ask you some questions and create a

form. You can also customize the form in the way you want.

Exercise :

Use the wizard to create a form that depends on (employee- table)

Steps:

Select [forms] and click [New] as in the following figure.

Notice the appearance of [New Form] as follows:

Select (Form Wizard) and highlight (Employee Table) as a record source for

the form.

Click (ok).

Notice the appearance of following [Form Wizard]:

Available

Field box

Selected box

fields

Click the button ''>> '' to insert all the fields or click the button '' > '' to select

the fields you want to insert in the selected box field then click [Next] so, the

following figure appears:

Click next , the following figure appears:

Select (Layout View) you want for the form and click next.

Click (Next) , the following figure appears:

Highlight the Style of form you want for the form and click (finish).

Notice the appearance of the form as in the following figure:

Notice:

The design of the form created by the wizard can be modified if you desire.

2- Creating forms using ( Design View):

Creating a form using (Design View), looks like sitting at a table surrounded by

useful tools to carry out the tasks assigned for you.

Exercise:

Using (Design View) to create a form depending on (Employee Table):

Steps:

Select (Forms) then click (New) as before:

From (New Form), select (Design View) and click (Ok) so, the (Form

appears in (Design View)

Notice the appearance of (Field List) of Employee Table.

Select the first field and click (shift). From (list), select the last field to select

all fields.

Insert the fields to (Detail Section), as in the following figure.

From (View), select (Form View) as in the following figure:

Notice the appearance of the form as (Form View) as in following figure:

Form Sections

The form consists of four basic sections, they are:

Form Header

It includes the data inserted at the head of the form, such as the company's

address, institution or any other statement that clarifies the nature of the data it

displays.

Form Footer

It includes the data inserted at the foot of the form, such as the total of employees

and (form conclusion).

Page Header

It includes data that appear at the head of every page such as (Field

Titles)displayed by the form. It includes also the slogan of the company or

institution whose data are displayed by the form.

Page Footer

The page footer includes the data put at foot of every form page such as (Page

Number and Date) etc.

Exercise:

Display and add data for sections of (Employee Form) created in the previous

exercise. To do this, follow these steps:

From (view Menu), select (Design View).

Activate the icons (Page Header/Footer) and (Form Header/Footer) as in the

following figure:

Notice the appearance of (Form Sections) in (Design View) as in the following

figure:

Select the (label) tool from (Tool Box) as in the following figure:

Insert (label) once in (Form Header) and another in (Form Footer).

Edit in the first tool (Employees Data) and in the second edit "Ministry of

Education."

Make the necessary formats.

Display the form in (Form View) so the figure appears as follows:

Ways of (Form View):

You noticed that it is possible to use more than a way to display (Form View)

and to shift these ways, you can select (Form View) as follows:

1- From the toolbar ( Form Design) select one

of the three ways of (View)

2)From (View menu) select one of the three

ways of( View)

Notice that there is a new way for displaying the form. It is (Datasheet).

The following figure shows the different ways for the (Form) according to (Form

View).

Through (Form View) of "Datasheet" you can display the records in columns and

row formats, so you can view many of the records at the same time.

Through (Form View), you can go through a single record at a time.

Record Navigation:

In both ways of (Form View) and (Datasheet View), you can navigate across

records, add a record, reach to a certain record or view the total number of records in the file of data.

The following figure illustrates the functions of the navigating buttons in the form.

1. The first record.

2. The previous record.

3. The present record, you can edit the record number and click on the entry key to

navigate to a certain file.

4. Next record.

5. The last record.

6. New record.

• Add, Delete Records:

You can add and delete records in (Form view).

1. This button displays a new record to fill.

2. This button deletes the present record.

• Sort, Fitter and Find Data:

You can sort records in the form, according to data in a single field.

Steps:

1. Sort the records in (descending / ascending) order.

2. Click on one of the buttons of (filter Factor) to decide on the records that will be

displayed in the form.

3. Search for values and exchange them in records.

Exercise:

1. With your teacher's help, attempt to do the following:

2. Navigate across the records of the (Employee Table).

3. Add and delete an employee's data.

4. Sort the data of a column name in an (ascending) order and search for a

certain name.

The calculated values in Forms

Frequently, we need to do some mathematical calculations in the form or the

report. These calculations sometimes depend on the stored data in the data tables.

For example, if data in the fields of the table include the items of the salary for an

employee, there is no need after calculating the net salary to store it in table of

data.It is useful here, to calculate the net salary on loading the (Employee Form)

in the computer's memory only.

To calculate the net salary, insert [Textbox] from the [Toolbox] and we

insert also the mathematical expression that calculates the net salary.

Exercise:

Find the ratio of 25% of the salary to refer to the monthly incentive in the

(Employee Form).

Steps:

Open [Employee] Form in [Design View]

Select [textbox and insert it in [Details] as in the following figure:

Notice the appearance of a new element [unbound] for the fields of (Employee-

Table) as shown in the previous figure.

Select the new element and click [properties] in toolbar of (Form Design) so the

following figure appears.

Select [Data] in front of [Control Source] click the button "" To open

[Expression Builder).

With the help of [Expression Builder] edit [salary] * 0.25 as in the

following figure:

Click [Ok] so "Properties" appears this time, but it contains the required expression

as in the following figure:

Close "Properties" and change the title [New Text] to form the" monthly

incentive"

Select [Form View]. So the form will be shown as follows:

Compare between the salary value as stored entity and the monthly incentive value

as a calculated statement?

Sub Forms

It is a form inserted in another form (the maim form). We call (The form inside the

main form) a (Sub-Form). We refer to it as (Frame Form- or subordinate form)

The effectiveness of (Sub – Forms) appears when we want to view Data from

tables bearing the relationship of (One-Many) for example; you can create a form

with a sub-form inside it to view data from (Department-Employee) tables.

When we display the name of a certain department, the data of the employees who

work in this department appear in this department only but on viewing another

department name, data of the employees appear in the second section only. This is

only when the relationship is (One to Many) of (Department Table).

The primary form clarifies the data of (One) a (linking relation) where as the sub

form clarifies the data of (Many) of the same relationship.

The main form is linked to the sub form so that the latter can display only the

records connected to the present record in the main form.

Nested levels:

If you put every sub form in a main form, the main form can include any number

of sub forms .With the maximum of seven nested levels of sub forms.

This means that you can put a sub form in a main form; and put another sub form

inside another sub form and so on. For example, you can make the main form

display the clients. While the sub form displays the orders. The sub form displays

the last details of requests.

Exercises:

We will try to use the main/ the sub forms to display (Department – Name) from

(Department Table) and display the employees of this department from

(employees) table.

Steps:

Select creating a new form whose record source is (Employee) table

Insert the table fields in (Details Section)

Select the sub form tool from toolbox as follows:

Insert the tool in [Details section] , so the following figure appears:

Select (Table or Query) and click (Next) and notice the appearance of the

following table:

Select the Table of ( Employee ) so its fields appear in the (Available

Field)window

Click the button ">>" to insert all the fields of (Employee- Table) in the

selected field box.

Click ( Next ) and select ( Employee- View) for each department according

to the ( Department- Number) as in the following figure .

Click (Finish) so the wizard terminates and we return to(Design View)

Display the form in ( Form View) so the (Sub Form View) inside the Primary

Form appears as shown:

Notice that there are two navigating buttons, one for the main form and the other

for the sub form.

On changing the department name using the main form navigating buttons, the

sub form will display only the employees of this department.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]