0% found this document useful (0 votes)
8 views

Lecture

Uploaded by

lemanovil36
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Lecture

Uploaded by

lemanovil36
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

MS ACCESS

LECTURE 3
Creating Forms.

• As we have mentioned that form is a type of database object that primarily used to enter or
display data in the database. Most forms bound to one or more table and queries. A form data
source refers to the fields in an underlying table of query.
Characteristics of a form are:-
• Focus on one record at a time
• Can display fields from more than one table
• Can also display pictures and other objects
• Can contain button know as macros for opening , printing and other activities
• Data entry form can be created through Form wizard or design view. Once a table with fields is
available it is easy to create a form using wizard.
Creating a form using Blank Form tool

• This can be a very quick way to build a form, especially if you plan to put
only a few fields on your form.
• On the Create tab, in the Forms group, click Blank Form

Access opens a blank form in Layout view, and


displays the Field List pane.
Cont…

• 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.
• To add a field to the form, double-click it or drag it onto the form.
• Use the tools in the Header/Footer group on the Design tab to add a logo, title, or
the date and time to the form.
Creating a form using Form wizard

• On the Create tab, in the Forms group, click Form Wizard


• Follow directions on the pages of form wizard
Cont…
• If you want to include fields from multiple tables and queries on your form,
do not click next or Finish after you select the fields from the first table or
query on the first page of the Form Wizard. Instead, repeat the steps to
select a table or query, and click any additional fields that you want to include
on the form. Then click next or Finish continuing.
• On the last page of the wizard, click Finish.
Cont…
• Double-click Create form by using wizard. Form Wizard
• Click on Tables/Queries drop down menu to choose the table or query
from which you want to create a form select tblStudent table, select the
fields you want to be included in the form, when done click Next
• Choose form layout from the various form layout options and click next.
• Select a style for the form from the list and click next.
• Assign a title to your form. In this case study, the title will be STUDENT’S
DETAIL FORM. Click Finish to see it.
Changing the appearance of the form.
• While the form is still open, click Design
View from the View menu or click
Design View icon on the toolbar. The
form appears in Design view.
• Drag the top edge of the Form Footer
down to enlarge the Detail section of the
form.
• Select Phone_No field and its label and then
drag the mouse pointer down in order to
increase vertical space between Phone_No
field and Student_Name fields.
Cont…
• Adjust vertical space between Student_Name field and Student_ID so that it
matches with vertical space between Phone_No and Student_Name
• Click on each field label and modify it by removing underscore.
• Select all fields and their labels by dragging the mouse pointer over them.
Every field and label appear with a handle.
• Right-click on selected fields and labels and click properties on short-cut
menu. Multiple selection dialogue box will appear as shown in the next slide
Cont…
• In Height text box, type new height 0.22 to increase the height each field and label from default
height of 0.1771.
• Click any empty area on the form to remove selection on the fields and labels.
• Now select only Student_ID and Phone_No fields and right-click them to display short-cut menu.
• Click Properties. Multiple selection dialogue box appears.
• Type Width of 0.7.
• Close Multiple selection dialogue box by clicking Close button (X)
• Click FormView from View menu or View button from toolbar
Replacing navigation buttons with command
buttons.
• When using Form wizard to create Access form, the form is automatically
given a set of pre-defined buttons called navigation buttons. These buttons
perform the same common tasks such as addition of records, moving to the
next or previous record, etc. The navigation buttons can be replaced with
command buttons
Cont…
• Open Student form in Design
View and click ToolBox from
toolbar if it is not yet available in
Design View window.
• Before adding any command button,
custom wizard in the toolbar must be
selected, select it by clicking on it and it
should look like in figure on the right side
of this slide.
Cont…
• From the Toolbox select command button tool and click on to the form, in
the position where the Add button is to be placed. Command button wizard
will appear.
Cont…
Note:
Command Button Wizard consists of button actions placed in five different categories.
Categories.
The Go To Next Record and Go To Previous Record actions are placed in Record
• Navigation Categories
The Add New Record, Delete Record and Save Record actions are placed in Record
• Operations category.
The Close Form action is placed in Form Operations category
• Select category and corresponding button action as required in our example and by
following button sequence in our form design as shown in the next slide
Cont…
• Repeat the same procedure for all
command buttons which are
Delete, Save, Next, Previous (Back)
and Close on the form.
• Drag the buttons on their correct
places and align them. If needed
resize each button to fit its name.
• Once all command buttons are
complete, click Form view button
and click each button to test them
Removing navigation buttons.
• Now we do not need automatic navigation buttons any more on the form. We also
do not want those vertical line (Record Selectors) and horizontal line (Dividing
Lines). We must get rid of them. To remove them, follow the steps below
i. Open the form in Design view
ii. Right-click anywhere inside Form Footer section and the click Properties on
short-cut menu.
iii. Click Properties on short-cut menu. The Form window appears.
iv. Click the Format tab is not selected and scroll down to get to Record
Selectors, Navigation Buttons and Dividing Lines sections. Change their default
values to Yes
v. Close the Form dialogue box and click View button.
vi. Close the form
Renaming the form.
• Notice that our form is named as STUDENT’S DETAIL FORM in
database window. This has to be renamed as frmStudent. To rename the do
the following:
i. Right-click the form. Drop-down menu appears.
ii. Click Rename. Type new name frmStudent.
Updating Database Records using Form.
• form is a type of a database object that is primarily used for entering or
displaying data in a database. You can also use a form as a switchboard that
opens other forms and reports in the database, or as a custom dialog box
that accepts user input and carries out an action based on the input. In this
case a form will be used as an object to update records in the database.
Cont…
• Database can be updated by adding new records, deleting some records or
changing some records. In this example, we will update the database by
adding new record into tblStudent table. Follow the steps below to enter
this record Student ID: S0007 Name: Magaya Mrisho Telephone No:
0753837380
i. Open the frmStudent form
ii. Click Add butt. All the fields become blank.
iii. Enter new record.
iv. When finished, click Add button. The fields become empty again.
v. Click Close
Searching record and updating.
• Database updating is one of the most frequently activities that occur in the
database. This starts by searching for specific record to be updated. When
found, the updating is going ahead. The following details relate to searching
information for updating.
Navigating through records.
• Use the Next and Previous button to navigate either to the next record or previous record
respectively based on the position of the record in the table
Use Find button to search for a specific record from the table
Searching a record
• Click Find button to search a specific record to edit, The Find and Replace window will
appear
• In the “Find What” field type the specific information to be searched from the table and
click find next, a form will display the record related to the searched information
Editing Record.
• Click Find button to search a specific record to edit, The Find and Replace window will
appear
• In the “Find What” field type the specific information to be searched from the table and
click find next, a form will display the record related to the searched information
• Edit the record accordingly and click Save button
Deleting a record
• Click Find button to search a specific record to edit, The Find and Replace window will
appear
• In the “Find What” field type the specific information to be searched from the table and
click find next, a form will display the record related to the searched information
• Delete the record by clicking a delete button
Exiting a form
• Click Close button to close the form
Creating Queries.

• As it was mentioned earlier, a query is a deliver item in a database meant to


answer specific questions that related to the information in the database.
• Queries can be used to find data that’s meet a certain condition that you
specify.
• There are two ways to create a query, using query wizard and query design
view.
Create a query using query wizard.

• Click create button


• Then choose query wizard.

• The query wizard dialogue box will be displayed.


Cont…
• Then, choose simple query wizard and click Ok
• You will be ask to specify which table or query can provide fields for your
new query
• After selecting a table or query, you may decide if to include the entire field
available in a selected table or query
• Then click ok
• Write the name for your query and click Finish
Create Query in Design View.
• A query can be thought as a record to find all records satisfying certain
criteria so that they can be displayed in a form of a record. Queries may be
made up of records that were created from fields from several tables.
• Queries can be used in much the same way that you use tables. There are six
different types of query in Access, each used for different purposes. They
are: Select query, Crosstab query, Make-table query, Update query, Append
query and Delete query.
• We will focus on only Select query
Query 1: Display record of each book.
• Here, we will need book details: book
titles, borrowed date and returning date
from tblBook table.
• Steps to create the query are as
follows:
i. In the database window, click Queries
object and select Create Query in
Design View.
ii. Click New. The following window
appears.
Cont…
• Double click Design View to open
a query window. A query window
appears with Show Table dialogue
box floating on top of it
Cont…
• With tblBook table selected, click
Add, and then Close. A table
popup on the new query wizard
appears as in the figure on the right
side of this slide.
Cont…
Selecting fields.
• The next step is to select the fields that will be used the query. Follow the
steps below.
• i. Double-click Book_ID, Student_ID, Book_Title, Borrowed_Date and
Returning_Date in turn to place them in the query grid.
ii. Click the run button on the toolbar.
iii. Click Save button and the query as qryAllBooks. Click close icon (X).
Cont…
• Note: Query can also be placed on the query grid by:
Dragging the field name from the table onto the top line of the query grid
Clicking the Down arrow in the Field cell in the query grid to display a list of field names
from which you can select.
Query 2: Display all books that are borrowed and
students who borrowed those books.
• Here, we will need book details such as Book_Title, Borrowed_Date and Returning_Date
from tblBook table and student details which are Student_Name, and Phone_No from
tblStudent table.
i. Open a query window by following the steps shown earlier
ii. Add tblBook table to the query window.
iii. Add tblStudent table to the query window.
iv. Close Show Table
v. Double click all required fields from both tables to place them in the query. Follow
the order as the fields appear in the figurer in the next slide
Cont…
vi. Click run button to run the query.
vii. Save the query name as qryStudentBook
viii. Close the query.
exercise
• Create query that extracts student name, student ID and all book titles that
were borrowed by students
• The query should base on details from tblStudent and tblBook tables.
Generating Reports.
Creating a report using Wizard
• A report is an effective way to present your data in a printed format. Because you have
control
over the size and appearance of everything on a report, you can display the information the
way you want to see it. Reports can be created from a table or query as data source. Access
allows you to create a report whose detail information come from multiple data sources. For
example, the tblBook and tblStudent tables can be used to generate a report of all students
with their respective book titles they have borrowed. In Access, reports can be created using
wizard or Design view. In this example, we will create a report by using wizard. We will use
both tblStudent and tblBook table as data source.
Cont…
i. Select Reports object on database window and double click Create
Report by Using Wizard.
ii. Select a table or query from which a report will extract the data and select
field from available fields. In this example, we select three fields namely
Book_Title, Borrowed_Date and Returning_Date from tblBook table.
Note: Fields can be selected from more than one table if they are linked
• iii. Select Student_Name from tblStudent table.
Cont…

iv. Click Next to continue in the next page of


Report Wizard.
v. Select by tblStudent in order to view the
data by Student_Name
Note:
• The way of viewing data can be changed by
selecting which details to be viewed first. For
example you can view report by data from student
table as shown in the figure in the next slide.
Cont…
vi. Click Next to go to the next page of report wizard where grouping of data
in the report can be added.
vii. Double Click on one of the field from which grouping will be made from
the left hand side of the wizard as in figure in the next slide. Then the field will
be selected to the right hand side on report layout and will be in blue color. In
this case, double-click Borrowed_Date.
viii. Click “Grouping Options” to obtain more grouping options by specifying
grouping intervals example for the date fields can be on monthly, weekly or
daily basis.
Cont…
ix. Click Next to display sorting records part
of report wizard and sort order can be
specified, for example, by ascending and
descending based on the field selected and
click next.
The sort order options are shown in the next
slide.
x. Select stepped report layout and portrait
orientation from the report layout part of
Report Wizard and click Next.
xi. Select casual report style from available
styles in Report Wizard and click Next
xii. Save a report by giving it an appropriate
name and select either to preview the Report
or to modify Report Design and click Finish
Customize report appearance.
• Here you need to apply the same technique you used in customizing
appearance of the forms. You need to customize report labels and field
labels by realigning, repositioning and resizing them to allow full display of
each part of information. In addition, change the font size of report title to
16.
• To go to the Design view of report, View button from toolbar or select
Design View from View menu.
Exercise.
• Use query qryStudentBook created earlier to create a report that prints all
books that were borrowed and students who borrowed those books.

You might also like