Вы находитесь на странице: 1из 126

Table of Contents

1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14.

INTRODUCTION TO MICROSOFT ACCESS CREATING A DATABASE PRIMARY KEYS AND INDEXING DATA IMPORTING A SPREAD SHEET INTO ACCESS CREATING QUERIES USING MICROSOFT ACCESS ADVANCE QUERIES WORKING WITH FORMS ADVANCE FORMS WORKING EXAMPLE OF FORMS WORKING WITH REPORTS ADVANCE TOPICS IN MS-ACCESS APPENDIX KEYBOARD SHORTCUTS GLOSSORY

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

Chapter 1 Introduction to Microsoft Access

In this chapter we will discuss Database Defined What is Database Management System (DBMS)? Tasks of DBMS: Microsoft Access Description Todays era as we all know referred to as an era of Information technology. Information is the key to decision making. Large business firms maintain huge databases to derive information of various sorts to facilitate their decision- making bodies to prepare perfect strategies. Information is closely related to data, which is the root base of all the operations. Before we proceed further lets see what are the basic terms Data and Information and what is the difference between them. Data: Data are the raw facts collected using a systemic process. The word data is the plural of datum, which means facts. Data is the basis from which information can be drawn i.e. we interpret the raw data to derive something meaningful. Data is always in huge or bulk amounts. It is difficult to make conclusions using data, but data can be processed to do so. Information: Information is the processed facts. Information is derived after processing the huge or bulky data. It is in a very condensed and symmetric form and help in decision- making.

Database Defined
A database is an organized collection of data. Thus is a collection of information organized and presented to serve an assigned purpose. Example of database is a dictionary where words are arranged alphabetically, or telephone directory where subscriber names are listed in an alphabetically.

What is Database Management System (DBMS)?


A database Management system is essentially a collection of interrelated da ta and a set of programs to access this data. This collection of data is called the Database. The primary objective of DBMS is to provide a convenient environment to retrieve and store database information. Database system support single- user and multi- user environment.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

A Database System consists of two parts namely: Database Management System and Database Application. Database Management System is the program that organizes and maintains the information where the Database application is the program that lets us View, retrieve and Update information stored in the DBMS. DBMS has to protect database against unintentional changes that could be caused by users and application. A database is generally composed of various data files. A file is a collection of related records. A record is a collection of related fields. A Field is a collection of character. A character may be an alphabet, a number or a special symbol. A character is the smallest piece of information in a database. It cannot be broken down further into parts.

Entity
An entity is any object, place, person, concept or activity about which an enterprise records data. Each of the following is an entity: building, room, chair, course, machine, employee etc. An entity always has certain set of propert ies, which helps in its reorganization. These properties are fixed for an entity and any change in these entity marks a transaction. An entity type or entity set is a group of similar objects of concern to an origination some common examples of entity set are Job Position, employees, inventories of raw material etc.

Attributes
An attribute is the characteristics property of an existing entity. The difference between attribute type and attribute instance has to be understood. Attribute type is the property of entity type, and attribute is the property of entity instance. The terms data items, data elements, data fields, items, elementary items, or object property also refers an attribute.

Attributes values
Each attribute of an entity set has a particular value. The set of all possible values that a given attribute can have are called its domain. Entity Set EMPLOYEE Attribute Name Ration card No Address Skill Annual salary Value Mr. Pramod Gour 12-2000-12-67-21 63, Ward No-2, Amber Computer Professional 15,20,000

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

In the above example employee is an entity with the attribute name, ration card no, address, skill and annual salary. Database Management System offers the following services: Data Definition: It is a method of data definition and storage. Data Maintenance : it checks whether each record has fields containing all information about one particular item. For examples in an employee database all information about the employee like name, address, designation, salary, dept _name are recorded. Data Manipulation: Allows data in the Database to be inserted, updated, deleted and sorted. Data Display: This method helps in viewing data. Data Integrity: This ensures the accuracy of the data

The elements of database can be defined in another way, the logical arrangements of records in a database: Character: Character is a collection of 8 bits i.e. one byte can be called as one character. Field: A field is a collection of various characters. The smallest piece of meaningful information in a file is called Data item or filed. Record: A Record is a collection of related fields. File: A File is a collection of related records. Database: Database is a collection of related data-files

Tasks of DBMS:
1. 2. 3. 4. 5. 6. 7. Creating of files (deciding the fields, their types & sizes) Adding a new record to a database Rearranging record into some meaning order. Searching a record in a database to find a specific piece of information Printing data from database to get a formatted report. Editing a record in a database. Deleting a record from a database.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

Microsoft Access Description


Microsoft Access is a Database Program. Access is a Relational Database management system. Microsoft Access is a powerful program to create and manage your databases. The data contained in a database is viewed as a set of twodimensional tables that present the data in rows and columns. You can built relationship between tables that contain different fields to put together reports that draw form a number of different tables and thus display the information you need to see. It has many built in features to assist you in constructing and viewing your information. Access is much more involved and is a more genuine database application than other programs such as Microsoft Works. This reading material will help you get started with Microsoft Access and may solve some of your problems, but it is a very good idea to use the Help Files that come with Microsoft Access, or go to Microsoft's web site located at http://microsoft.com/office/access/default.htm for further assistance. Using Microsoft Access, you can manage all your information from a single database file. Within the file, you can use:

Tables to store your data. Queries to find and retrieve just the data you want. Forms to view, add, and update data in tables. Reports to analyze or print data in a specific layout. Data access pages to view, update, or analyze the database's data from the Internet or an intranet.

Microsoft Access database is a collection of data and objects, such as tables, queries, or forms, related to a particular topic or purpose. The Microsoft Jet database engine manages the data. For example, suppose the phone numbers of your suppliers are stored in various locations: in a card file containing supplier phone numbers, in product information files in a file cabinet, and in a spreadsheet containing order information. If a supplier's phone number changes, you might have to update that information in all three places. In a database, however, you only have to update that information in one place the supplier's phone number is automatically updated wherever you use it in the database. First of all you need to understand how Microsoft Access breaks down a database. Some keywords involved in this process are: Database File, Table, Record, Field, Data-type. Here is the Hierarchy that Microsoft Access uses in breaking down a database.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

Database File: This is your main file that encompasses the entire database and that is saved to your hard-drive or floppy disk. Example) StudentDatabase.mdb Table: A table is a collection of data about a specific topic. There can be multiple tables in a database. Example #1) Students Example #2) Teachers Field: Fields are the different categories within a Table. Tables usually contain multiple fields. Example #1) Student LastName Example #2) Student FirstName Datatypes:Datatypes are the properties of each field. A field only has 1 datatype. FieldName) Student LastName Datatype) Text

A table is a collection of data about a specific topic, such as products or suppliers. Using a separate table for each topic means that you store that data only once. This results in a more efficient database and fewer data-entry errors. Tables organize data into columns (called fields) and rows (called records). For example, each field in a Products table contains the same type of information for every product, such as the product's name. Each record in that table contains all the information about one product, such as the product's name, supplier ID number, units in stock, and so on.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

Chapter 2 Creating a Database

In this chapter we will discuss About designing a database Creating Databases Creating a Table Data Types The Market Database Add a field to a table Delete a field from a table As seen in the earlier chapter the key factor any relational database management system are databases, which are themselves collection of tables. So the first step in to start with Ms-Access is to create a database. Access provide two method to create a database- one creating a database manually without any help, the other way is to use a database wizard. Beginners may use the wizard to create a databases, but it is always preferred to use a Blank Database to create a database.

About designing a database


Good database design ensures that your database is easy to maintain. You store data in tables and each table contains data about only one subject, such as customers. Therefore, you update a particular piece of data, such as an address, in just one place and that change automatically appears throughout the database. A well-designed database usually contains different types of queries that show the information you need. A query might show a subset of data, such as all customers in London, or combinations of data from different tables, such as order information combined with customer information. Follow these basic steps when designing your database. Determine the purpose of your database The first step in designing a database is to determine its purpose and how it's to be used:

Talk to people who will use the database. Brainstorm about the questions you and they would like the database to answer. Sketch out the reports you'd like the database to produce.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

Gather the forms you currently use to record your data.As you determine the purpose of your database, a list of information you want from the database will begin to emerge. From that, you can determine what facts you need to store in the database and what subject each fact belongs to. These facts correspond to the fields (columns) in your database, and the subjects that those facts belong to correspond to the tables.

Determine the fields you need in the database Each field is a fact about a particular subject. For example, you might need to store the following facts about your customers: company name, address, city, state, and phone number. You need to create a separate field for each of these facts. When determining which fields you need, keep these design principles in mind:

Include all of the information you will need. Store information in the smallest logical parts. For example, employee names are often split into two fields, FirstName and LastName, so that it's easy to sort data by LastName. Don't create fields for data that consists of lists of multiple items. For example, in a Suppliers table, if you create a Products field that contains a co mma-separated list of each product you receive from the supplier, it will be more difficult to find only the suppliers that provide a particular product. Don't include derived or calculated data (data that is the result of an expression). For example, if you have a UnitPrice field and a Quantity field, don't create an additional field that multiplies the values in these two fields. Don't create fields that are similar to each other. For example, in a Suppliers table, if you create the fields Product1, Product2, and Product3, it will be more difficult to find all suppliers who provide a particular product. Also, you will have to change the design of your database if a supplier provides more than three products. You need only one field for products if you put that field in the Products table instead of in the Suppliers table.

Determine the tables you need in the database Each table should contain information about one subject. Your list of fields will provide clues to the tables you need. For example, if you have a HireDate field, its subject is an employee, so it belongs in the Employees table. You might have a table for Customers, a table for Products, and a table for Orders. Determine which table each field belongs to When you decide which table each field belongs to, keep these design principles in mind: Add the field to only one table. Don't add the field to a table if it will result in the same information appearing in multiple records in that table. If you determine that a field in a table will contain a lot of duplicate information, that field is probably in the wrong table. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

For example, if you put the field containing the address of a customer in the Orders table, that information will probably be repeated in more than one record, because the customer will probably place more than one order. However, if you put the address field in the Customers table, it will appear only once. In this respect, a table in a Microsoft Access database differs from a table in a flat file database such as a spreadsheet. When each piece of information is stored only once, you update it in one place. This is more efficient, and it also eliminates the possibility of duplicate entries that contain different information. Identify the field or fields with unique values in each record In order for Microsoft Access to connect information stored in separate tables for example, to connect a customer with all the customer's orders each table in your database must include a field or set of fields that uniquely identifies each individual record in the table. Such a field or set of fields is called a primary key. Determine the relationships between tables Now that you've divided your information into tables and identified primary key fields, you need a way to tell Microsoft Access how to bring related information back together again in meaningful ways. To do this, you define relationships between tables. You may find it useful to view the relationships in an existing well-designed database such as the Northwind sample database.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

Creating Databases
When Access is started, the following screen appears:

Selecting Blank Database will create a new database in the location that you specify and proceed to the Access main window. Selecting Database Wizard will create a new database in the location that you specify and will start the Wizard. The Wizard is a step-by-step process that assists you in creating a new database. You pick different items from lists that Access will present to you. After selecting all the items, Access goes and automatically generates the tables, forms, etc necessary for the database. Selecting Open an Existing Database allow you to open a database that has been already created. The bottom part of the window will list the most recent databases that have been used. To open one, double click the file name or click the file name once and click the OK button. If the file is not in the list, double click "More Files . . ." and the Open dia log window will open allowing you to switch to appropriate drive and directory where the database is stored. We are going to select Blank Database and click the OK button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

10

The Open dialog window appears:

We are going to create this on the C: drive. 1. In the Save in: box, click the down arrow and select the entry where the line ends in "(:)". 2. For the File Name box, highlight the entry (db1.mdb) and type in "market". (you can leave the .mdb extension off and Access will add it for you automatically) 3. Click the OK button. The database has now been created in the C: drive. The main window for Access should now be showing.

Even though you have not done anything with your database yet, a new file has been Tip: created. This means if you decided that you did not want to continue with this database, you should go in to the Windows Explorer and delete the market.mdb file. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

11

Creating a Table
Now that we have created the database, we want to create a table to put information in to. To create a new table, click the Table tab on the main window and click the Ne w button.

The New Table window will appear:

Here is an explanation of the five options listed. Option Datasheet View Description Places you in the datasheet view with predefined fields. This method allows for direct data entry in to the table. Allows you to create the fields necessary, allowing for different options to Design View be set (name, data type, etc). Table Wizard Leads you through laid out steps that assist you to develop the new table. Import information in to the database and sets up the database according to Import Table the fields in the imported file. Link Table Link to a table that exists in a different database. We are going to use the Design View. Click the Design View in the list and click the OK button. The following Design View screen will appear:

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

12

Each row in the screen represents a field that has a field name, data type and optional description.

List of Items on the Screen Item Description Field Name Name of the field. Can have spaces. Type of data that is to be stored. Can be things like text, numbers, data/time, Data Type memo, etc. A description of the field. This is optional and will show in the status bar Description when the user is in that field on a form or in the datasheet view. Sets the field to be a primary key (ensures that no two records contain the same value for that field). Generally in file we have fields that help to Primary identify a record uniquely. The value of these fields do not repeat in any Key record. These fields are called primary key. It is preferred that the value off these fields is not left empty. i.e. the are not NULL. Field Size Allows you to set the size of the field (i.e. limit text entries to 10 characters). Format in which to display the values for the field to the users. (i.e. show a Format postal code with the space in the middle). Decimal Set the number of decimal places to show for a numeric field. Places Restrict the data that the user can enter. Used to ensure correct data entry. Input Mask (i.e. for a postal code, you want to make sure that the first character entered is a letter and not a number. Caption If you want a different name to appear for the column header in the Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

13

datasheet view or the label in form view. (i.e. originally call field "emp#" but you want the labels to say "Employee Number" Default Value Validation Rule Validation Text Required A value to be entered in to the table if the user does not enter one. Can be used to validate the information the user enters. (i.e. make sure the value is always less than 100) Allows you to set the message that appears if the validation rule fails. If nothing is entered for this value, Access will display a default message. If turned on, the user must enter something in this field in order to save the record.

Data Types
Most of the items above are optional. If you enter nothing in them, your table will still function properly. Something that can not be avoided is selecting a data type. This distinguishes the type of information to be stored in the table. Item Text Memo Description A character string with a maximum length of 255 characters. A character string with a maximum length of 64,000 characters. Usually used for descriptions of items (i.e. describing a truck would probably require more than 255 characters). A memo field cannot be used as a primary key. Various types of numbers. There are many different subtypes to select from in Field Size. They are Double (15 places, 8 bytes), Single (7 places, 4 bytes), Long Integer (-2.1 to +2.1 billion, 4 bytes, no decimals), Integer (32 to +32 thousand, 2 bytes, no decimals) and Byte (values 0 to 255, 1 byte, no decimals). Access will automatically generate a number for this field. Usually used as a unique identifier for primary key purposes. Used to store logical results from True or False results. Be careful as -1 stands for Yes and 0 stands for No. Used for storing dates and times. The format can be changed in the Format box. Used for storing numbers (not necessarily in a dollar format). Can hold 15 places to the left of the decimal and four places to the right. Takes up 4 bytes. Used for OLE compliant applications (i.e. linking a portion of a spreadsheet to the table) Used for storing web addresses.

Number

AutoNumber Yes/No Date/Time Currency OLE Object Hyperlink

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

14

The Market Database


Now that we looked at the main items in the Design View window, let's create a few of our own entries. The example we are going to use is Farmer Joe's Market. In the table below is a list of the different fields we are going to create for our table. To create a new field, move to the Field Name in a blank row and type the field name. Even though you can have spaces in the name, we will not include any in our field names. Field Name ProductName Category Distributor Cost Price MarkUp Description Name of the product. Category product falls in. Company where we buy the product. Data Type Text Text Text Other Information Field Size of 30 Field Size of 20 Field Size of 50 Size Size of of

Price we buy product for. Currency Amount we increase the price from Field Number cost. Single Number Field Single

QuantityInStock Number of units in stock.

We want the Product Name to be our primary key as we will never have a product with the exact same name as another. To set the Product Name as the primary key: 1. Place the mouse on the selection box beside Product Name (looks like a gray stub) and the mouse will change to a . When it changes, click the mouse button. 2. Click the Primary Key button. Now that we have all the fields entered in the table, we have to save the table. To save the table: 1. Click the or select File, Save from the menu. 2. Following screen appears. Type Products in the Table Name box.

3. Click the OK button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

15

Close the Table To close the table, click the button or select File, Close from the menu.

Entering Values in Table In the Access main window, you should see an entry called "Products" under the Table section. To enter values in the table, click the table name (Products) and click the Open button. The datasheet view will open. It looks like a spreadsheet- like format. Each row represents one record and each column represents the specific field. Here is a list of keys for entering values: Key Tab Shift Tab Arrow Keys Enter Description Moves to the next field to the right. If you are in the last field for the record, when the Tab key is pressed, it will move you to the next record below. - Moves to the next field to the left. If you are in the first field for the record, it will move you to the next record above the current record. Moves in the direction of the key pressed. Moves to the next field to the right. If you are in the last field for the record, it will move you to the next record below the current record.

Whenever you leave the current record (the row on you are working one), the record will be saved. Example, If you are in the fourth field and make a change, if you hit the Tab key, it will move to the next field to the right, but does not save the record. If you press the Up or Down arrow key, this will move to a different record and the changes to the current record will be saved automatically.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

16

Here is a list the entries to enter: ProductName Category Apples Coke Fruit Pop Distributor Cost Price Eatery Fruits $0.25 Coca-Cola Ltd. $0.93 MarkUp 0.33 0.15 0.3 0.15 0.15 0.22 0.25 0.23 0.25 0.18 0.15 0.17 QuantityInStock 65 64 22 24 33 15 40 33 40 20 79 45

Dad's Oatmeal Cookies Diet Coke Diet Pepsi Fruit Loops Pop Pop Cereal

Dad's $3.47 Cookies Ltd. Coca-Cola $0.93 Ltd. PepsiCo Ltd. $0.88 Nabisco Ltd. $2.57 Kellogs Ltd. $3.58 Post Ltd. $3.14 Eatery Fruits $0.30 Christie Ltd. $2.30 PepsiCo Ltd. $0.87 Kellogs Ltd. $3.97

Double Fudge Cookies HoneyCombs Cereal Oranges Fuit Oreo Cookies Pepsi Pop Rice Kripsies Cereal To close the table, click the

button or select File, Close from the menu.

Add a field to a table


Add a field to a table in Design view 1. Open the table in Design view. 2. To insert the field within the table, click in the row below where you want to add the field, and then click Insert Rows on the toolbar. To add the field to the end of the table, click in the first blank row. 3. Click in the Field Name column and type a unique name for the field. 4. In the Data Type column, keep the default (Text); or click in the Data Type column, click the arrow, and select the data type you want. 5. In the Description column, type a description of the information this field will contain. This description is displayed on the status bar when adding data to the Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

17

field and is included in the Object Definition of the table. The description is optional. 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 unique 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. Note To add a field to a linked table in another Microsoft Access database, you must open its source database. If the linked table is from another application, you must open the source file with that application to add a field

Delete a field from a table


When you delete a field, remember that if other database objects contain references to the deleted field, you need to delete those references as well. For example, if a report includes a control bound to the deleted field, Microsoft Access won't be able to find the data from the field and will generate a message. You can't delete a field that's part of a relationship-you must delete the relationship first. Delete a field from a table in Design view 1. Open the table in Design view. 2. Select the field or fields you want to delete. To select one field, click that field's row selector. To select a group of fields, drag through the row selectors of those fields. 3. Click Delete Row on the toolbar. Delete a field from a table in Datasheet view 1. Open the table in Datasheet view. 2. Click the field selector of the column you want to delete. 3. On the Edit menu, click Delete Column. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

18

Assignments: Based on your above knowledge try to solve the following assignments: Prepare a database called- Office I. Create the following tables: 1. Employee:
Empid CAG/97/ 01 CAG/97/ 02 CAG/97/ 03 CAG/97/ 04 CAG/97/ 05 CAG/97/ 06 CAG/97/ 07 CAG/97/ 08 CAG/97/ 09 CAG/97/ 10 CAG/97/ 11 CAG/97/ 12 CAG/97/ 13 CAG/97/ 14 CAG/97/ 15 CAG/97/ 16 CAG/97/ 17 CAG/97/ 18 CAG/97/ 19 CAG/97/ 20 CAG/97/ 21 Employee Name Amit Vinay Kishori Lal Pramod Gour Vijay Agarwal Nilesh Nathawat Parul Jain Pankaj Jain Vipin Handa Rakesk Arora Hars h Parnami Dilip Kungwani Ritu Jain Priyanka Dheer Anit Dutt Arvind Agarwal Rakesh Goyal Sunita Goyal Prashant Dixit Govind Vinay Katyal DOB 23-Dec-1977 12-Dec-1961 17-Mar-1963 18-Oct-1962 19-Oct-1960 15-Dec-1979 14-Dec-1977 18-Oct-1977 17-Nov-1977 18-Nov-1965 14-Mar-1972 8-Oct-1980 9-Oct-1970 1-Dec-1978 12-Dec-1963 14-Jan-1978 15-Nov-1978 18-Oct-1969 15-Dec-1978 12-Dec-1975 12-Dec-96 Address Jawahar Nagar Raja Park Adarsh Nagar AG Colony AG Colony AG Colony Jawahar Nagar Raja Park Raja Park AG Colony Adarsh Nagar Jawahar Nagar AG Colony Govind Nagar Jawahar Nagar Govind Nagar Raja Park Adarsh Nagar AG Colony Govind Nagar AG Colony

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

19

2. Employee Details: (Primary Key : Empid)


Employee Id CAG/97/ 01 CAG/97/ 02 CAG/97/ 03 CAG/97/ 04 CAG/97/ 05 CAG/97/ 06 CAG/97/ 07 CAG/97/ 08 CAG/97/ 09 CAG/97/ 10 CAG/97/ 11 CAG/97/ 12 CAG/97/ 13 CAG/97/ 14 CAG/97/ 15 CAG/97/ 16 CAG/97/ 17 CAG/97/ 18 CAG/97/ 19 CAG/97/ 20 CAG/97/ 21 DOJ 24-Dec-1999 12-Dec-1981 17-Mar-1989 18-Oct-1987 19-Oct-1979 15-Dec-1999 14-Dec-1999 18-Oct-1999 17-Nov-1999 18-Nov-1999 14-Mar-1995 8-Oct-1999 9-Oct-1995 1-Dec-1999 12-Dec-1987 14-Jan-1999 15-Nov-1999 18-Oct-1985 15-Dec-1986 12-Dec-1993 12-Dec-97

Department
Railway Railway P&T CAG AG AG Railway AG AG Railway AG Railway P&T P&T AG Railway P&T AG Railway Railway CAG Audit Audit

Audit

Audit Audit

Audit

Audit Audit

Section Report CASS Report Report Report CASS GD CASS GD Report Library & Training Library & Training GD GD Report Library & Training GD GD Library & Training Library & Training CASS

Designation SO AAO AO AO AO AAO DAG DAG SO DAG DAG SO AAO AAO CLE RK CLE RK CLE RK SO AAO AAO SO

Basi c 4589 5687 7698 7897 7847 5689 13545 14597 4595 14569 12896 6987 8956 6987 4698 4896 4489 4698 4589 7596 6598

IT Deduction 850 850 1000 1000 1000 1000 1200 1200 850 1200 1200 1000 1200 1000 850 850 850 850 850 1000 1000

Deputation

Y N N N N N N N N N Y Y Y N Y N N N N Y Y

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

20

3. Course: (Primary Key : Nil)


Empid CAG/97/ 01 CAG/97/ 06 CAG/97/ 07 CAG/97/ 08 CAG/97/ 09 CAG/97/ 12 CAG/97/ 14 CAG/97/ 16 CAG/97/ 17 CAG/97/ 19 CAG/97/ 04 CAG/97/ 05 CAG/97/ 06 CAG/97/ 10 CAG/97/ 13 CAG/97/ 19 CAG/97/ 03 CAG/97/ 06 CAG/97/ 09 CAG/97/ 13 CAG/97/ 16 CAG/97/ 18 CAG/97/ 19 Course Oracle DBA Access IT Audit Access Dbas e Internet Oracle DBA Oracle DBA Oracle DBA IT Audit Internet Internet Dbas e Oracle DBA Dbas e Basic Dbas e Internet Oracle DBA Internet Oracle DBA Access Oracle DBA

4. GPF Register: (Primary Key: Empid)


EmpId CAG/97/ 01 CAG/97/ 03 CAG/97/ 04 CAG/97/ 06 CAG/97/ 08 CAG/97/ 12 CAG/97/ 14 CAG/97/ 16 CAG/97/ 18 CAG/97/ 21 GPF Advance 25000 45870 45856 47000 56000 25800 45000 65000 75000 62000 Return Period 12 15 12 15 20 15 15 12 18 18

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

21

II. Design a table, which can keep track of the attendance of all the employees in the organization. While preparing the table keep in mind that the table is not an attendance register, but it keep track of only the leaves taken by the employees in their service period.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

22

Chapter 3 Primary Keys and Indexing Data


In this chapter we will discuss About primary keys Set or change the primary key About indexing fields Multiple- field indexes Create an index Creating Relationships

About primary keys


The power of a relational database system such as Microsoft Access comes from its ability to quickly find and bring together information stored in separate tables using queries, forms, and reports. In order to do this, each table should include a field or set of fields that uniquely identifies each record stored in the table. This information is called the primary key of the table. Once you designate a primary key for a table, Access will prevent any duplicate or Null values from being entered in the primary key fields. There are three kinds of primary keys that can be defined in Microsoft Access: 1. AutoNumbe r primary keys : An AutoNumber field can be set to automatically enter a sequential number as each record is added to the table. Designating such a field as the primary key for a table is the simplest way to create a primary key. If you don't set a primary key before saving a newly created table, Microsoft Access will ask if you want it to create a primary key for you. If you answer Yes, Microsoft Access will create an AutoNumber primary key. AutoNumber primary keys in a replicated database There are additional considerations if your table will be used with database replication.

If fewer than 100 records are routinely added between synchronizing replicas, use a Long Integer setting for the FieldSize property to take up less disk space.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

23

If more than 100 records are routinely added between synchronizing replicas, you should use Replication ID for the FieldSize property setting to prevent records from being assigned the same primary key value in each replica. Note, however, that an AutoNumber field with a Replication ID field size produces a 128-bit value that will require more disk space. 2. Single-field primary keys: If you have a field that contains unique values such as ID numbers or part numbers, you can designate that field as the primary key. You can specify a primary key for a field that already contains data as long as that field does not contain duplicate values or Null values. 3. Multiple-field primary keys : In situations where you can't guarantee the uniqueness of any single field, you may be able to designate two or more fields as the primary key. The most common situation where this arises is in the table used to relate two other tables in a many-to- many relationship. For example, an Order Details table can relate the Orders and Products tables. Its primary key consists of two fields: OrderID and ProductID. The Order Details table can list many products and many orders, but each product can only be listed once per order, so combining the OrderID and ProductID fields produces an appropriate primary key. Each product can be listed only once per order. Another example would be an inventory database that uses a field part number of two or more fields (part and subpart). If you are in doubt about whether you can select an appropriate combination of fields for a multiple-field primary key, you should probably add an AutoNumber field and designate it as the primary key instead. For example, combining FirstName and LastName fields to produce a primary key is not a good choice, since you may eventually encounter duplication in the combination of these two fields. In a multiple-field primary key, field order may be important to you. The fields in a multiple- field primary key are sorted according to their order in table Design view. You can change the order of the primary key fields in the Indexes window.

Set or change the primary key


1. Open a table in Design view. 2. Select the field or fields you want to define as the primary key. To select one field, click the row selector for the desired field. To select multiple fields, hold down the CTRL key and then click the row selector for each field. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

24

3. Click Primary Key on the toolbar. Note 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.

About indexing fields and records in an Access database


An index helps Microsoft Access find and sort records faster. Access uses indexes in a table as you use an index in a book: to find data, it looks up the location of the data in the index. You can create indexes based on a single field or on multiple fields. Multiple-field indexes enable you to distinguish between records in which the first field may have the same value. Deciding which fields to index You'll probably want to index fields you search frequently, fields you sort, or fields that you join to fields in other tables in queries. However, indexes can slow down some action queries such as append queries, when the indexes for many fields need to be updated while performing these operations. The primary key of a table is automatically indexed, and you can't index a field whose data type is OLE Object. For other fields, you should consider indexing a field if all the following apply:

The field's data type is Text, Number, Currency, or Date/Time. You anticipate searching for values stored in the field. You anticipate sorting values in the field. You anticipate storing many different values in the field. If many of the values in the field are the same, the index may not significantly speed up queries.

Multiple-field indexes If you think you'll often search or sort by two or more fields at a time, you can create an index for that combination of fields. For example, if you often set criteria for LastName and FirstName fields in the same query, it makes sense to create a multiple-field index on both fields. When you sort a table by a multiple- field index, Microsoft Access sorts first by the first field defined for the index. If there are records with duplicate values in the first field, Microsoft Access sorts next by the second field defined for the index, and so on. You can include up to 10 fields in a multiple- field index.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

25

Create an index to find and sort records faster


You can create indexes based on a single field or on multiple fields. Multiple-field indexes enable you to distinguish between records in which the first field may have the same value. Create a single-field index 1. Open a table in Design view. 2. In the upper portion of the window, click the field that you want to create an index for. 3. In the lower portion of the window, click in the Indexed property box, and then click Yes (Duplicates OK) or Yes (No Duplicates). Create a multiple-field index 1. Open the table in Design view. 2. Click Indexes on the toolbar. 3. In the first blank row in the Index Name column, type a name for the index. You can name the index after one of the index fields, or use another name. 4. In the Field Name column, click the arrow and select the first field for the index. 5. In the next row in the Field Name column, select the second field for the index. (Leave the Index Name column blank in that row.) Repeat this step until you have selected all the fields you want to include in this index. Note The default sort order is Ascending. Select Descending in the Sort Order column of the Indexes window to sort the corresponding field's data in descending order.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

26

Table Relationships
To prevent the duplication of information in a database by repeating fields in more than one table, table relationships can be established to link fields of tables together. Follow the steps below to set up a relational database: 1. Click the Relationships button on the toolbar. 2. From the Show Table window (click the Show Table button on the toolbar to make it appear), double click on the names of the tables you would like to include in the relationships. When you have finished adding tables, click Close .

3. To link fields in two different tables, click and drag a field from one table to the corresponding field on the other table and release the mouse button. The Edit Relationships window will appear. From this window, select different fields if necessary and select an option from Enforce Referential Integrity if necessary. These options give Access permission to automatically make changes to referential tables if key records in one of the tales is deleted. Check the Enforce Referential Integrity box to ensure that the relationships are valid and that the data is not accidentally deleted when data is added, edited, or deleted. Click Create to create the link.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

27

4. A line now connects the two fields in the Relationships window.

5. The datasheet of a relational table will provide expand and collapse indicators to view subdatasheets containing matching information from the other table. In the example below, the student address database and student grade database were related and the two can be shown simultaneously using the expand feature. To Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

28

expand or collapse all subdatasheets at once, select Format | Subdatasheet |Expand All or Collapse All from the toolbar

Assignment: Create all possible relationship between the all tables created in the Office database, designed in chapter 2.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

29

Chapter4 Importing a Spreadsheet into Access


In this chapter we will discuss Importing a Spreadsheet into Access Begin the import process Selecting the Data Select the appropriate worksheet Specify whether column headings are present. Choose a destination type. To prepare a database, the user may have many options. It is not always necessary that the user prepare the database using Ms-Access only. User may go for various other options including: preparing the database in nay other database management system likes FoxPro, dbase etc. one of the most common and easy way use to prepare the database is the use of ms-excel. One the data has been prepared; a user may wish to transport it from one application to another. This process of shifting objects prepared in one application into another is called importing. It is also possible to import tables form one application into Ms-Access. In the following paragraph we will discuss how to transfer or import a spreadsheet created in ms excel into Access

Importing a Spreadsheet into Access

1. Begin the import process. To get started, simply click on the File menu, select Get External Data and then choose the Import option on the next menu that appears.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

31

Selecting the Data 2. Select the file to import. Here's where you select the Microsoft Excel spreadsheet that will serve as the source of data for your new database. Use the browser window presented to navigate through the file system to the correct spreadsheet. When you locate the file, double-click on it to continue.

3. Select the appropriate worksheet. After you select the spreadsheet to import, you'll be presented with a new screen asking you to select the Worksheet or Named Range that you wish to import. Most likely, you'll want to accept the default option of Sheet1, unless you have a more complex Excel file. Notice that a preview of the data is provided in the bottom portion of the window. Take this opportunity to give the data a quick glance to ensure that it looks like the right data source. Don't worry about the formatting or column contents at this point, we'll work on those later. Once you complete this step, press the Next button to continue.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

32

4. Specify whether column headings are present. Often, Microsoft Excel users utilize the first row of their spread sheet to provide column names for their data. In our example file, we did this to identify the Last Name, First Name, Address, etc. columns. In the window shown below, ensure that the "First Row Contains Column Headings" box is checked. This will instruct Access to treat the first row as names, rather than actual data to be stored in the list of contacts. Click the Next button to continue.

5. Choose a destination type. If you're working with a brand-new database, as we are, you'll want to check the "In a New Table" radio box and press the Next button to continue. If you were importing data into an existing database, you could specify the destination table here. Click the Next button to continue.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

33

Chapter 5 Creating Queries using Microsoft Access

In this chapter we will discuss Queries Creating the Query Selecting the Fields Sorting the Results Removing a field from the query

Queries
Queries allow you to be selective about the information to be retrieved. For example, maybe we only want to see all the products in the Pop category that have a cost price less than .80. Access has many types of queries you can run, but we will concentrate on the Select1 Query. The big advantage Access has is that you build queries through a graphical interface. Before when information was to be retrieved from the database, the user had to type in a big line SQL code to get the information. Access avoids this method by allowing you to basically "click and drag" the fields you want to report on. After you select the entire field necessary for the query, Access builds the SQL in the background, sends it to the database and returns the result in a datasheet format.

Creating the Query


To create a new query, click the Query tab on the main window and click the New button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

35

The New Query window will appear:

We are going to use the Design View. Click the Design View in the list and click the OK button. Now that have pick the type of query we want, we have to select which tables are going to be a part of the query. The Show Table window should be showing:

This screen lists the possible tables and queries (yup, you can base a query on a saved query) to select from to build the query. We only have the one table. Click the Products name in the Table Tab area and click the Add button. This adds the table to the query. Click the Close button. You should now see the Products table in the Select Query window.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

36

Selecting the Fields We now have to choose which fields we want in the query. There are two ways: 1. Drop-down list box In the first blank column, click once in the Field row. If it now already showing, a small down arrow will appear by to the right of the white box. Click the down arrow. This will list the fields that can be selected.

Click ProductName in the list. 2. Click and drag from Table box In the Select Query, you can see the Products table (let's call it the Product table box). In this box, it lists all the fields in the Product table that can be selected for the query. To select the field, click and hold the left mouse button on the Category field in the Product table box. While holding the mouse button down, drag the mouse on top of a blank column and release the mouse button. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

37

You should now have the ProductName and Category fields selected in the Field row of the two columns.

Running the Query Even though we have not entered any criteria (restrictions like only the Pop entries), we can execute the query. To run the query, click the Run button or select Query, Run from the menu. The following screen should appear:

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

38

This is called a dynaset. It is a temporary table that is created and contains the values from your query. Be careful though as any changes performed to the data will be reflected back in the Products table. Why would you want to do a change then? For example, let's say we know we made a typing error on the ProductName for one of the products in the Pop category. We could write a query to look for just the Pop category and scan through the dynaset for the ProductName to correct. This would be much easier than looking through hundreds of entries in the main table. To return to the Design window, click the Design from the menu. button or select View, Design View

Sorting the Results The results can be sorted in Ascending (A to Z) or Descending (Z to A) order. To sort the ProductName in Ascending order, click the white Sort box in the ProductName column. A small down arrow will appear to the right of the box. Click the down arrow and select Ascending from the list.

To remove the sorting, click the down arrow in the Sort box and select (not sorted).

Showing a Field By default, when you select a field to have in the query, it shows in the dynaset when the query is run. But, there may be an instance where you may want a field in your query but not to show up in the query. For example, let us say that someone wants a list of products that cost us more than Rs.1 but they do not need to know the prices for the product (they just care about the products that are more than Rs.1). In this case, you would include the ProductName and Cost Price, with Cost Price having a criteria of greater than one. If you click the Show box under the Cost Price column, this would prevent the price from being displayed in the dynaset, but you would only get the products that are more than one dollar showing because of the criteria entered for Cost Price.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

39

Removing a field from the query Sometimes you may have no need for a field you selected. To remove the Category field, use one of the following: 1. Move the mouse pointer to the top of the Category column. The mouse pointer will turn to a . When it switches to the down arrow, click the mouse button once and the column will become highlighted. Press the Delete key on the keyboard or click the Cut button on the toolbar. 2. Click once anywhere in the Category column and select Edit, Delete Column from the menu.

SQL View As mentioned previously, the main advantage that Access has is the graphical user interface for creating queries. The SQL code for the query is automatically generated in the background. If you want to see the SQL code that is generated by the query, select View, SQL View from the menu. This will show you the SQL code. You can make modifications in this window if you know SQL. BUT, as soon as you make any changes, you can not go back to the Design View. To return to the Design View, select View, Design View from the menu.

Save the Query To save the query: 1. Click the Save button or select File, Save from the menu. 2. The Save As window appears:

Type in "List of Products". 3. Click the OK button. Closing the Query window To close the query window, click the

button or select File, Close from the menu.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

40

Assignments: Using the Office database Created in Chapter 2 try preparing the following queries: 1. Find the Names and empid of all the employees in the sorted order. 2. Find the Name of all employees who live in AG Colony. 3. Find the list of all employees, who were born after 31/12/78. 4. Find the Names of all employees, who work in Railway Audit. 5. Find the list of all AAO, whose basic salary is more than 6000. 6. Find the empid, basic, DA, HRA, and GPF Deduction of all employees. Following information can be use to prepare the query: a. DA= 52% of Basic. b. HRA= 600 for basic<4200 HRA = 800 for basic >=4200 and basic <=6500 HRA= 800 for basic >6500 c. GPF Deduction = 12 % of basic. 7. Find the empid of all employees, whose GPF Advance is more than 47000 but the return period is less than 15 months. 8. Find the empid of all employees, who have done the Access course. 9. Find the empid of all employees who have done more than 2 courses. 10. Find the empid of all employees who have done oracle training.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

41

Chapter 6 Advance Queries

In this chapter we will discuss Specific Criteria for a Query Simple Criteria Query Advanced Criteria for a Query OR Conditional Query AND Conditional Query Calculation Query

Specific Criteria for a Query


The main purpose of queries is to see the a specific subset of data from a table. If we did not enter in any criteria, would have something that is the same as the datasheet view for the tables.

Simple Criteria Query


We are going to create a new query. 1. Click the Query tab in the main window (if not already there) and click the new button. 2. Click Design view and click the OK button. 3. Click the Product table entry. 4. Click the Add button. 5. Click the Close button. 6. In the first column, click the Field box and then click the down arrow. Select ProductName from the list. 7. In the second column, click the Field box and then click the down arrow. Select Cost Price from the list. 8. In the third column, click the Field box and then click the down arrow. Select Category from the list. This gives us the fields we want to use for the query. Now we are going to enter some criteria so that we only get a specific subset of information returned in the query.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

43

Let's say we only want the entries in the "Pop" category. 1. In the Criteria box in the Category column, type in "Pop" (without the quotations and not case sensitive). 2. Press the down arrow key on the keyboard. See what happen to the entry. Access automatically puts quotations around the phrase because it knows that it is a text string. So, you have the option of leaving them on or you can type them in yourself. Run the query by clicking the Run You should see the following results: button or select Query, Run from the menu.

To return to the Design window, click the Design from the menu.

button or select View, Design View

Dealing with Numbers There are many different ways the we can deal with numbers. The most commons ones are when we are looking for values less than something or values that are greater than something. Let's look for all products that have a Cost Price less than 90 cents. 1. Once in the Design View, delete the "Pop" criteria for Category by highlighting the Criteria box and pressing the Delete key on the keyboard. 2. In the Criteria box in the Cost Price column, enter in "< .9". 3. Run the query by clicking the Run button or select Query, Run from the menu. On the status bar of the dynaset window, it will say how many records fit the criteria. There are 12 records in our table, but from this query we just ran, we only see 8, so we Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

44

know the query worked. Also, if you quickly scan down the Cost Price category, you should notice that all the values are greater than 90 cents. To return to the Design window, click the Design from the menu. button or select View, Design View

Let's try another one. Now we are looking for all the products that cost between 2 and 3 dollars. 1. Once in the Design View, delete the "<.9" criteria for CostPRice by highlighting the Criteria box and pressing the Delete key on the keyboard. 2. In the Criteria box in the Cost Price column, enter in "between 2 and 3". (yup, that's right, you do enter in the word "between") 3. Run the query by clicking the Run button or select Query, Run from the menu. You should only have two entries appearing:

Dealing with Text We already dealt with handling a simple text query in the first example. This query works well if you are looking for exact values. What if we want to looking for a string inside the text (i.e. all entries that have the letter 'o' in them). In these instances, we use the wildcard option. This uses a asterick. What this does is looks for zero or many characters in substitute Let's look for all entries that end with the letter 'e'. For this, we wan to look at all entries where there are no characters before or many characters before the 'e' on the end. 1. Once in the Design View, delete the "Pop" criteria for Category by highlighting the Criteria box and pressing the Delete key on the keyboard. 2. In the Criteria box in the ProductName column, enter in "*e" (without quotations). 3. Press the down arrow key on the keyboard. The "*e" turns to "Like *e". Access does this for you automatically. It converts it into the way that it needs to run the query. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

45

4. Run the query by clicking the Run

button or select Query, Run from the menu.

You should get three rows returned in the dynaset:

To return to the Design window, click the Design from the menu.

button or select View, Design View

Now let's look for entries where there is the letter 'o' anywhere in the text. 1. Once in the Design View, delete the "ProductName" criteria for Category by highlighting the Criteria box and pressing the Delete key on the keyboard. 2. In the Criteria box in the ProductName column, enter in "*o*" (without quotations). 3. Run the query by clicking the Run button or select Query, Run from the menu.

To return to the Design window, click the Design button or select View, Design View from the menu. Once in the Design View, delete the "ProductName" criteria for Category by highlighting the Criteria box and pressing the Delete key on the keyboard. If you want to quit and take a break, close Access by clicking the button or select File, Exit from the menu. When Access asks you to save the query, click the No button. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

46

Advanced Criteria for a Query


We will now look at more advanced queries using and / or conditions. We will also look at Calculation Queries. If you are coming back from a break, create a new query with the ProductName, Cost Price and Category fields. OR Conditional Query The OR condition allows us to select different sets of criteria for the same field. For example, we are looking for all products that have the letter 'b' or the letter 'k' anywhere in the text. 1. If you haven't done so already, delete any criteria that is there already. 2. In the Criteria box in the ProductName column, enter in "*b* or *k*" (without quotations). 3. Press the down arrow key on the keyboard. The phrase turns to "Like "*b*" Or Like "*k*"". Access does this for you automatically. It converts it into the way that it needs to run the query. 4. Run the query by clicking the Run button or select Query, Run from the menu. You should have the following results:

AND Conditional Query The AND condition allows us to set the criteria for the query based on multiple fields. For example, we are looking for all products that are in the Cookies category and more than Rs.3.00. 1. If you haven't done so already, delete any criteria that is there already. 2. In the Criteria box in the Category column, enter in "cookies" (without quotations). 3. In the Criteria box in the Cost Price column, enter in "> 3" (without quotations). Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

47

4. Run the query by clicking the Run You should have the following results:

button or select Query, Run from the menu.

To return to the Design window, click the Design from the menu.

button or select View, Design View

We can also have an AND within the criteria for one field. For example, we want all the products that have the letter 'o' and the letter 'e' in them. So, in order for them to show up in the dynaset they have to have BOTH criteria to qualify. 1. If you haven't done so already, delete any criteria that is there already. 2. In the Criteria box in the ProductName column, enter in "*e* and *o*" (without quotations). 3. Run the query by clicking the Run button or select Query, Run from the menu. You should have the following results:

To return to the Design window, click the Design from the menu.

button or select View, Design View

Calculation Query Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

48

A calculation query allows us to perform arithmetic and string calculations on the field in the query. Now why would you want to do this? Well, sometimes there is no need to store a fields in a table as it can be calculated by other fields that are stored in the table. For example, in a Wages table for employees, there is a field "HoursWorked" and another called "WageRate". Every month we need to get what the Gross Amount will be for their paycheque. It would make no sense to create a new field in the table design for Gross Amount as we already have the two fields that make up that field value. So in order to save space in the database, we would not create a new field in the table design, but we would do a calculation query to calculated the amount of Gross Amount by multiplying HoursWorked by WageRate. Eliminating these unnecessary fields is called normalization. Let's do an example. We will calculate the amount of tax on our products. 1. If you haven't done so already, delete any criteria that is there already. 2. In one of the blank columns to the right, click once in the Field box. 3. This is optional. I find it to be quite a pain to type a lot information in that tiny box. While the blinking cursor is in the Field box, move the mouse pointer on top of the Field box and click the RIGHT mouse button. A pop-up menu will appear. Select Zoom from the list. The Zoom window will appear. This just makes it easier to type information in as the area and the font is larger. 4. Type in the following (an explanation will follow): TotalCost:[Cost Price] * 1.14 5. Click the OK button. The field box should look like this now:

6. Run the query by clicking the Run button or select Query, Run from the menu. 7. To return to the Design window, click the Design button or select View, Design View from the menu.

Item

Description

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

49

[Total Cost] : [Cost Price]

This is the name of the expression. This is what will appear as the column title in the dynaset. This signifies the end of the expression name and the beginning of the calculation. This is the field from the table we want to select. Important items here: a. Name has to be in square brackets. This signifies that the value is from a table. b. Name has to be spelled the exact same was as it is in the Table design. (if it is not, when the query is run, it will pop up a screen asking for value for the Field Name typed in).

* 1.14

Arithmetic operator. Static value that can be typed in.

To close the query window, click the button or select File, Close from the menu. Click the No button when it asks to save query.

Assignments: Using the Office database Created in Chapter 2 try preparing the following queries: 1. Find the names, department and designation of all employees who have done more than 2 trainings. 2. Find the empid and the name of all the employees, who have joined the service after the date, 31/12/1995. 3. Find the name of all the employees who joined the service before the age of 22 but are not on deputation. 4. Find the Names of all employees, whose IT deduction is more than 750. 5. Assuming DA to be 52%, find the names of all the AAO, who have a DA more than 3000. 6. Find the name and the designation of all the employee, who have done a training on access and have AG as their Department. 7. Find the list of all employees, who do not have done any course. 8. Create a Table Senior_employee using the Make Table query, which contain the name, empid, basic of all employees who have completed at- least 10 years of service. 9. Add a new field called bonus in the above table Senior_employee, using a query

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

50

Chapter 7 Working with Forms

In this chapter we will discuss Forms Creating Forms Form Screen Adding a Label Object The Field List box Form View Saving the Form

Forms
A form is a type of a database object that is primarily used to enter or display 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. Most forms are bound to one or more tables and queries in the database. A form's record source refers to the fields in the underlying tables and queries. A form need not contain all the fields from each of the tables or queries that it is based on. A bound form stores or retrieves data from its underlying record source. Other information on the form, such as the title, date, and page number, is stored in the form's design.

Creating Forms
There are two ways to enter information in to the database. There is the Datasheet view in the Table area. With this option, you can see several records at one time, depending on the size of the screen. The other option is using a Form. Forms allow users to enter and view one record at a time. This is usually less confusing for the user as there is not as much clutter on the screen to confuse them. The forms can be customized by changing everything from the type of font to the colors used.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

51

Creating the Form To create a new form, click the Forms tab in the main window and click the Ne w button.

The New Form window will appear:

We are going to use the Design View. Click the Design View in the list. Click the down arrow and select "Products" from the list. Click the OK button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

52

Form Screen Here is the display of the Form Screen:

The gray background area is the work area where objects will be placed. The toolbar below the menu shows list of different options to select from. The Toolbox is a display of the different types of objects that can be placed on the background.

Adding a Label Object A label object is the equivalent to a title. It a static object, so it does not change as you go from one record to the next. Since we are dealing with Farmer Joe's Market, let's add in a title for it on our form. 1. 2. 3. 4. In the Toolbox, click the button. The mouse pointer will change to Click once near the top of the form. A blinking cursor will appear. Type in "Farmer Joe's Market" Press the Return key or click once anywhere else on the form. .

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

53

We now have a label that looks like this:

Adding a Text (Control) Object A Text Object will be the one that is most commonly used. These types of fields are the ones that change depending on the which record you are on. They can handle data from the table itself or can contain calculations in them. There a two different ways we can use Text Objects. The Toolbox Button 1. In the Toolbox, click the button. The mouse pointer will change to 2. Click once below the "Farmer Joe's Title". 3. The following show appear: .

4. Take the mouse pointer and place it on top of the white 'Unbound' box. When the pointer changes to click the left mouse button once. 5. Type in "ProductName" and press the Enter key on the keyboard. The white box represents the information that is stored in that field in the table. Later when View this, this field will show us all the different products we have as we go from one record to the next. Using this method, you have to manually modify both the Text Object and the Label Object (this is the one that says "Text1"). You can modify the Label Objects by following steps 4 and 5 above. The Field List box 1. If the Field List box is not showing, click the Field List box toolbar. button on the

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

54

2. The Field List box should be showing and list the fields in the Products table:

3. Move the mouse pointer on top of ProductName in the Field List box. 4. Click and hold the mouse button on ProductName. While holding the button down, drag the mouse pointer below the other field that we created. 5. Release the mouse button. Using this method, the Text Object and Label Object are filled in automatically.

The Label Object is filled in with whatever the field name is unless the Caption option for that field in the Table Design was changed.

Form View
So far we have been working in the Design View, which really does not show a nice impression of the work you have been doing. The Form View shows the actual information that is stored in the tables. To switch to the form view, click the View button on the far left of the toolbar.

The Form View for the form should be displayed.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

55

Moving in the Form View Here is a list of the different ways to move around in the Form View. Item Description First record in the table. Previous record in the table. Next record in the table. Last record in the table. First record in the table. Ctrl First record in the table. Home Ctrl End Page Down Tab Shift Tab Arrow keys Home End Last record in the table.

Page Up Previous record in the table. Next record in the table. Go to the next field to the right. - Go to the next field to the left. Goes to the field in which ever direction you press. If you are in the last field on form, by pressing the down or right arrow will go to next record. First field on the form. Last field on the form.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

56

To return to the Design window, click the Design from the menu.

button or select View, Design View

Saving the Form


1. Click the Save button or select File, Save from the menu. 2. The Save As window appears:

Type in "ProductList". 3. Click the OK button.

Assignments: I. Design a database, which can keep track of advance ticket booking in a Cinema Hall. The database must keep track of: the name of the person who booked the ticket, the show number and date of the show for which the ticket was booked and the number of tickets booked. At this stage you need not keep track of the seat number of allocated during the booking of the ticket. After preparing, the database design a form that can help in data entry of the ticket booking. The following facts may be kept in mind while preparing the form: 1. There are only Four shows: Noon, Afternoon, Evening and Night. 2. A person cannot book more than five tickets at a single time. II. Prepare a form that can help in creating a database of the students during the time of admission in a college. Create following table for the above purpose: Student (EnrollNo, Name, Address, Phone, Percentage) Subjects (EnrollNo, Subject 1, Subject 2,Subject 3) There should be only a single form for the entry of data of both the tables i.e. there a 1:1 relationship between student and subject tables. The form must have comb boxes for subject 1 subject 2 subject 3 fields. The combo must display the list of all available subjects. It must take care that no two subjects of the student must be same.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

57

III. Create a Form for the data entry of the employees for the Office database created in chapter 2. The form should have the following appearance

Data Entry Form


Employee Id Employee Name

Department
Designation

Section

Basic

DA

CCA

HRA

Deputation Allowance

IT Deduction

Other Deduction

GPF Advance

GPF Deduction

Net Salary

Calculate

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

58

The following additional information may be used during the preparation of the form: a. DA= 52% of Basic. b. HRA= 600 for basic<4200 HRA = 800 for basic >=4200 and basic <=6500 HRA= 800 for basic >6500 c. GPF Deduction = 12 % of basic.

You are free to make some assumptions or modifications based on your practical knowledge or experience.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

59

Chapter 8 Advance Forms

In this chapter we will discuss Modifying Objects on Forms Properties of an Object Categories Form Creating a Title for Form Creating a Combo Box for the Categories

Modifying Objects on Forms


Now that we know how to put objects on the form, we will look at how you can modify them in different ways so they give the form a nicer appearance. Things to look at: selecting objects, resizing, moving, changing fonts, changing colors and removing objects. Selecting Objects You probably already know by now how to select an object. You click on it once and small resizing squares will appear on the edges and corner of the object.

After selecting an object, then you can perform what ever action on it. But, what if you want to change a lot of fields at once (i.e. change the fonts of all the fields to Arial) this method would become quite cumbersome. To select multiple fields at one time, hold the SHIFT key down on the keyboard as you click the fields you want to select. If you select a field that you did not mean to, just click the field one more time while holding the shift key down.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

61

Resizing Objects There will be instances where the size of the object will not be big enough. This could be where the product name is longer than the object box or changing the font size to something larger than the box is currently sized for. To resize an object: 1. Select the object (click ProductName). 2. After selecting the object, there should be a series of boxes on the sides and corners of the object. These are called Resizing Boxes. Place the mouse on one of the boxes. 3. The mouse pointer will change to a double headed arrow. Once it changes, click and hold the mouse button down. 4. While holding the mouse button down, drag the mouse in the direction the object is to be resized. When doing this a faint gray outline will follow the mouse. This indicates how big the object will be.

5. Release the mouse button when the gray outline is the size you need. Even the gray workarea can be resized: 1. Move the mouse pointer on top of the edge of the gray workarea. 2. The mouse pointer will change to . Once it changes, click and hold the mouse button down. 3. While holding the mouse button down, drag the mouse in the direction the area is to be resized. When doing this a faint gray outline will follow the mouse. This indicates how big the object will be. 4. Release the mouse button when the gray outline is the size you need. Moving Objects There are going to be times where you want to move the objects around to get a better look. To move a Label Object: 1. Select the "Farmer Joe's Market" title. 2. Move the mouse pointer anywhere on top of the box until the mouse pointer turns into a hand pointer. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

62

3. Once the mouse pointer changes, click and hold the mouse button. 4. While holding the mouse button down, drag the mouse in the direction the object is to be moved. As you drag the mouse around, a rectangle will follow the mouse. Position this rectangle where the object is to be moved. 5. Release the mouse button. For a Text Object, the process is a little different. If you follow the procedure above, both the Text and Label objects will move at the same time.

If this is what you are looking for, then great!! But many times, you are looking to move the Text Object a little closer to the Label Object. Let's move the ProductName closer to its Label Object. 1. Select the ProductName object. After doing this, you will see the normal resizing boxes as mentioned previously. But, if you look in the upper left corner of the objects, you should see larger boxes. We will use these boxes to move the objects independent of one another.

2. Move the mouse pointer on top of the big box for the Text Object until the mouse pointer turns into a pointed finger pointer. 3. Once the mouse pointer changes, click and hold the mouse button. 4. While holding the mouse button down, drag the mouse in the direction the object is to be moved. As you drag the mouse around, a rectangle will follow the mouse. Position this rectangle where the object is to be moved. 5. Release the mouse button. Changing the Font and Alignment of an Object Access comes with a wide variety of fonts, it will be more than likely that you do not want the same boring font for everything. To change the font of an object, select the object and use one of the options on the toolbar.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

63

Here is a list of some of the different options: Item Description Type of font (Arial, Times New Roman, etc) Size of the font. Make the font bolded. Make the font italicized. Make the font underlined. Make the font left aligned so text lines up on the left side of the object. Make the font center aligned so text is centered within object. Make the font right aligned so text lines up on the right side of the object. Changing the Colour of an Object There is a wide assortment of colours to select from for the objects. The process is similar to that of changing the font. 1. Select the object. 2. Click the down arrow for the Font Colour or the Background Colour.

3. Click the colour you want.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

64

Removing an Object To delete an object: 1. Select the object. 2. Press the Delete key on the keyboard or click the Cut Properties of an Object The Properties window lists all the specific details about an object. Items like the name of the object, colours used, font, size, etc. All the things we have been talking about (changing fonts or colours) can all be done through this Properties window, but as you can see, it is much easier just to use options on the toolbar. To see the Properties for an object: 1. Select the object (ProductName). 2. Click the Properties button on the toolbar. button.

Here is what the Properties window looks like:

If you want to see the Properties window for another object, just click the object and the Properties window will automatically change (you do not have to click the Properties button again if the Properties window is showing). To close the form window, click the button or select File, Close from the menu. Click the Yes button when it asks to save the form. This would be a good place to take a break if you are looking for one. To close Access, click the button in the upper right corner or select File, Exit from the menu. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

65

Categories Form We are going to create a new form that will allow us to select a category and show us all the products that are in that category. Here is a general layout of what will be done: 1. Place a Farmer Joe's Market title at the top of the form. 2. Create a Combo Box (drop-down box) to show a list of the different categories to select from. 3. Create a List Box to show which products are in the category we selected in the Combo box.

Creating a Title for Form


We are going to create a title for our form that says "Farmer Joe's Market". Then we will change the font to Arial, change the size to 14 and underline the title. Creating Title 1. 2. 3. 4. In the Toolbox, click the button. The mouse pointer will change to Click once near the top of the form. A blinking cursor will appear. Type in "Farmer Joe's Market" Press the Return key or click once anywhere else on the form. .

Changing the Font 1. If the Label Object is not selected (does not have the resizing boxes), click it once to select it. 2. Click the down arrow on the Font Type 3. Scroll through the list and click Arial. Changing the Size 1. If the Label Object is not selected (does not have the resizing boxes), click it once to select it. 2. Click the down arrow on the Font Size 3. Scroll through the list and click 14. box on the toolbar. box on the toolbar.

After changing the size of the title, you will have to resize the box surrounding the title.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

66

Underlining the Title 1. If the Label Object is not selected (does not have the resizing boxes), click it once to select it. 2. Click the Underline button on the toolbar.

Remember, if you do not like where the Label Object is positioned, you can move it to a more suitable position. Have a look at what we've done so far. To switch to the form view, click the View button on the far left of the toolbar. To return to the Design window, click the Design button or select View, Design View from the menu.

Creating a Combo Box for the Categories


We are now going to create a Combo Box (drop-down list box) to show the different categories to select from. This section will look at creating the Combo Box and changing the query the Combo Box is based on. Creating the Combo Box 1. In the Toolbox, click the 2. Click once under the title. Using the Combo Box Wizard Once you clicked the mouse, the Combo Box Wizard begins. The Wizard is a step by step, hand help process to completing a process. What happens is the Wizard will ask a question, you answer the question and click the Next button. You go through this process until the Wizard has collected all the information necessary. You can usually tell you are at the end of the Wizard when a finished checkered flag appears. Once the Wizard gets all the information, it automatically goes and creates the object for you. Sounds like a lengthy process, but in the end, it saves you a lot of time. 1. 1. We want to get the categories from the Products table. Click "I want the combo box to look up the values in a table or query" and click the Next button. button. The mouse pointer will change to .

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

67

2. A combo box can display information from a table or query that you have previously developed. We want the categories from the Products table. In the View area, click the Tables option. Click the Products table in the list and click the Next button.

3. The next step lists all the fields that are in the table or query that you can select from. Click the Category field on the left and click the button. This will put Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

68

the field on the right side in the Selected Fields area. Any fields in this area are displayed in the Combo Box. Click the Next button.

4. The next step does not really apply to us. This is for the instance where you have multiple fields in the Combo Box. It allows you to resize the columns. Click t he Next button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

69

5. In this step, you have the option of where to store the information that the user selects from the Combo Box. If you were using this form to retrieve information for the table, you could "Store that value in this field:" and select a field to store the item they pick from the Combo Box. We will not be storing the value. Click "Remember the value for later use." and click the Next button.

6. This is the last step in the Wizard as indicated by the finish flag. This is for contents the Label Object that is to appear to the right of the actual Combo Box. It is a title that lists what the Combo Box is for. Type in "Select a category:" and click the Finish button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

70

You should now see two new objects in front of you. One is the Label Object and the other is the Combo Box. The objects may need to be resized and moved. Have a look at what we've done so far. To switch to the form view, click the View button on the far left of the toolbar. Try it out! Click the down arrow and look at the selections.

You probably noticed that we have repeating values. We will look at how we remove the repeating entries in the next section. To return to the Design window, click the Design from the menu. button or select View, Design View

Removing Repeating Values from the Combo Box When we Viewed our Combo box, we saw repeating values (four Pop's, three Cookie's, etc). In our case, we do not want these repeating values. 1. Select the Combo Box. 2. If the Properties box is not showing already, click the Properties button on the toolbar. 3. In the Properties window, in the Name box, highlight and delete what is in there. Type in "CategorySelected". This gives the object a better name for us to reference than Combo4. 4. Click once on the Row Source box. This box contains the query that populates the Combo Box. 5. Click the button. This will take you in to the SQL Builder.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

71

6. By default, the Combo Box Wizard always includes the Primary Key field as part of the query to populate the Combo Box. We will not use this value so let's remove it. Highlight the ProductName column and press the Delete key on the keyboard. 7. Select View, Properties from the menu.

8. Click once in the Unique Values box. Click the down arrow and select Yes from the list. This will eliminate the repeating values. 9. Close the SQL Builder window, click the button. Click the Yes button when it asks to save the changes made in the SQL Builder. This will return you to the Form Design window.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

72

10. Back in the CategorySelected Combo Box Properties window, change the Column Count to 1. The reason is was two was because the Wizard originally selected the Categories and ProductName fields. 11. In the Column Width, change the value to 1. Now, let's look and see how things went. To switch to the form view, click the View button on the far left of the toolbar. Click the down arrow and look at the selections.

The repeating values have been removed and we only see one of everything. To return to the Design window, click the Design from the menu. Creating a List Box for the Categories 1. In the Toolbox, click the button. The mouse pointer will change to 2. Click once just below the Combo Box created previously. . button or select View, Design View

Using the Combo Box Wizard Once you clicked the mouse, the List Box Wizard begins. This Wizards works the same as the one for the Combo Box. 1. We want to get the products and distributors from the Products table. Click "I want the list box to look up the values in a table or query." and click the Next button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

73

2. A List Box can display information from a table or query that you have previously developed. We want our information from the Products table. In the View area, click the Tables option. Click the Products table in the list and click the Next button.

3. The next step lists all the fields that are in the table or query that you can select from. Click the ProductName field on the left and click the button. Also, click the Distributor field on the left and click the button. This will put the Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

74

fields on the right side in the Selected Fields area. Any fields in this area are displayed in the List Box. Click the Next button.

4. This step allows us to adjust the width of the columns for the display in the List Box. By default, Access wants to "Hide key column". We want the key column to be displayed (this is the ProductName field). Click the "Hide key column (recommended)" box. Once you do this, the ProductName column should appear. Click the Next button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

75

If you wanted to resize the column to make it wider or skinnier, you put the mouse pointer on the black line that divides the column titles.

The pointer will change to . When it changes, click and hold the mouse button. Next, drag in the direction you want to resize the column and release the mouse button when you get the size you need. 5. In this step, we select which value to that identifies the row we select. Click "ProductName" and click the Next button.

6. In this step, you have the option of where to store the information that the user selects from the List Box. If you were using this form to retrieve information for the table, you could "Store that value in this field:" and select a field to store the item they pick from the List Box. We will not be storing the value. Click "Remember the value for later use." and click the Next button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

76

7. This is the last step in the Wizard as indicated by the finish flag. This is for contents the Label Object that is to appear to the right of the actual List Box. It is a title that lists what the Combo Box is for. Type in "Products and Distributors" and click the Finish button.

You should now see two new objects in front of you. One is the Label Object and the other is the List Box. The objects may need to be resized and moved. Move the Label Object to be above the List Box. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

77

Have a look at what we've done so far. To switch to the form view, click the View button on the far left of the toolbar. You should see the following list:

To return to the Design window, click the Design from the menu.

button or select View, Design View

Linking the selection from the Combo Box to the List Box Now that we have both of these objects created, let's link them together. The goal is whenever we select a category from the Combo Box, we want the List Box to change and only show the products and distributors from the category selected. 1. Select the List Box just created. 2. If the Properties box is not showing already, click the Properties button on the toolbar. 3. In the Properties window, in the Name box, highlight and delete what is in there. Type in "ProductSelected". This gives the object a better name for us to reference than List6. 4. Click once on the Row Source box. This box contains the query that populates the Combo Box. 5. Click the button. This will take you in to the SQL Builder.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

78

6. Since we want to restrict the entries shown in the List Box depending of the value selected in the category Combo Box, we have to include the Category field in the query. In the first blank column, click once in the Field row. If it now already showing, a small down arrow will appear by to the right of the white box. Click the down arrow. This will list the fields that can be selected. Click Category in the list. 7. Now that we have the Category field in our query, we have to state the criteria. The criteria that we want to use is the Combo Box field called CategorySelected that is found on the Categories form. In the criteria box for the Category field, type in: Forms![Categories]![CategorySelected] You should have something now that looks like this:

8. Close the SQL Builder window, click the button. Click the Yes button when it asks to save the changes made in the SQL Builder. This will return you to the Form Design window. If you switch to the Form View and try this out....... nothing will work correctly. We have to specify one more thing. We have to tell Access to re-run the query every time we select a new category. 1. Select the CategorySelected Combo Box. 2. If the Properties box is not showing already, click the Properties toolbar. 3. Click the All tab in the Properties window. 4. Scroll down the list until you see "On Change" button on the

Anything that starts with "On ..." in the Properties window represents a conditional action you can force to be carried out. These areas allow you to program what can happen in certain conditions. In our example, we want the query for the ProductSelected List Box to be re-queried every time the CategorySelected Combo Box changes. 5. Click once on the On Change box and click the 6. The following window appears: button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

79

Click Code Builder from the list and click the OK button. 7. The Class Module window appears. This is the area where you do the programming in.

The item we want to change is the ProductSelected List box. Type in: ProductSelected. 8. As soon as you type in the period, a list box pops up of the different properties that can be changed for the object selected.

Scroll through the list and click Re-query. 9. Close the Class Module window by clicking the button in the window. Now let's try it out. Switch the Form View and select a category. Every time you pick a new category, the List Box should change.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

80

Chapter 9 Working Example of Forms

In this chapter we will discuss Price and Quantity Form Linking the Forms Together

Price and Quantity Form


We are going to create a another new form. This form will d isplay information about the price of a product and details regarding quantity. Here is a general overview of what will be done: 1. 2. 3. 4. 5. Place a Farmer Joe's Market title at the top of the form. Place a few fields from our table on the form. Create a Text Object that allows us to enter a number in. Create a Text Object that contains a calculation. Create a button to save the results.

The goal of the form is to show the cost price, mark up rate and retail costs. We will also show the quantity on hand. The user will also be able to enter the amount of new stock that arrives. Creating the Form To create a new form, click the Forms tab in the main window and click the Ne w button. We are going to use the Design View. 1. Click the Design View in the list. 2. Click the down arrow and select "Products" from the list. 3. Click the OK button. Let's save the form right away. 1. Click the Save button or select File, Save from the menu. 2. The Save As window appears. Type in "PandQInfo". 3. Click the OK button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

81

Creating a Title for the Form We are going to create a title for our form that says "Price and Quantity Info:".

1. 2. 3. 4.

In the Toolbox, click the button. The mouse pointer will change to Click once near the top of the form. A blinking cursor will appear. Type in "Price and Quantity Info for:" Press the Return key or click once anywhere else on the form.

You can spruce it up by changing the font to Arial, change the size to 14 and underline the title. Placing Fields from Products table on Form We are going to include the following fields from our table: ProductName, Cost Price, MarkUp, QuantityInStock. 1. If the Field List box is not showing, click the Field List box button on the toolbar. The Field List box should be showing and list the fields in the Products table. 2. In the Field List box, click and hold on ProductName. 3. Drag the mouse below the title and release the mouse button. 4. Delete the Label Object associated with ProductName. Click the Label Object to the right and press the Delete key on the keyboard. 5. In the Field List box, click and hold on Cost Price. 6. Drag the mouse to the left part of the form and release the mouse button. 7. In the Field List box, click and hold on MarkUp. 8. Drag the mouse below the Cost Price field and release the mouse button. 9. In the Field List box, click and hold on QuantityInStock. 10. Drag the mouse to the right of the Cost Price field and release the mouse button. More than likely you will have to rearrange and move the fields around. Try and move them around so they look like this:

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

82

If you wanted to clean this up some, you could edit the Label Objects associated with the Text Objects (i.e. put in correct titles, spacing, etc). Adding "Quantity Received" Text Object We are now going to add a Text Object that will allow the user the enter in the amount of new stock that was received for the particular product. 1. In the Toolbox, click the button. The mouse pointer will change to 2. Click once to the right of the MarkUp field. .

3. If the Properties box is not showing already, click the Properties button on the toolbar. 4. In the Properties window, in the Name box, highlight and delete what is in there. Type in "QuantityReceived". 5. In the Properties window, click once in the Format box. Click the down arrow and select "General Number" from the list. Now we have to change the Label Object to the right of the field. 1. Select the Label Object. 2. Move the mouse pointer on the Label Object. When the pointer changes to click the left mouse button once. This places you in the editing mode. 3. Use the arrow and backspace keys to remove the text currently there. 4. Type in "Quantity Received".

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

83

Adding "Retail Price" Text Object We are now going to add a Text Object that calculates the Retail Price of the product by multiplying the Cost Price by the MarkUp rate.

1. In the Toolbox, click the button. The mouse pointer will change to 2. Click once below the MarkUp field.

3. If the Properties box is not showing already, click the Properties button on the toolbar. 4. In the Properties window, in the Name box, highlight and delete what is in there. Type in "RetailPrice". 5. In the Properties window, click once in the Control Source. Type in =[Cost Price]*(1+[MarkUp]) This is the calculation that gives the Retail Price. Normally the contents of the Control Source is the field name. You can place calculations in the Control Source as long as you start them with an "=" sign. Also, remember that any fields to be used from the table associated with the form must be spelled the exact same way as they are in the table and must be include in square brackets. 6. In the Properties window, click once in the Format box. Click the down arrow and select "Currency" from the list. This displays the number with a dollar sign and two decimals. Now we have to change the Label Object to the right of the field. 1. Select the Label Object. 2. Move the mouse pointer on the Label Object. When the pointer changes to click the left mouse button once. This places you in the editing mode. 3. Use the arrow and backspace keys to remove the text currently there. 4. Type in "Retail Price". Adding "Total Quantity" Text Object We are now going to add a Text Object that will add the QuantityInStock with the QuantityReceived to give us the TotalQuantity in stock. This number will saved later in the QuantityInStock field. 1. In the Toolbox, click the button. The mouse pointer will change to 2. Click once below the QuantityReceived field. 3. If the Properties box is not showing already, click the Properties toolbar. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT .

button on the

84

4. In the Properties window, in the Name box, highlight and delete what is in there. Type in "TotalQuantity". 5. In the Properties window, click once in the Control Source. Type in =[QuantityInStock]+[QuantityReceived] This is the calculation that gives the Retail Price. Normally the contents of the Control Source is the field name. You can place calculations in the Control Source as long as you start them with an "=" sign. Also, remember that any fields to be used from the table associated with the form must be spelled the exact same way as they are in the table and must be include in square brackets. 6. In the Properties window, click once in the Format box. Click the down arrow and select "General Number" from the list. Now we have to change the Label Object to the right of the field. 1. Select the Label Object. 2. Move the mouse pointer on the Label Object. When the pointer changes to click the left mouse button once. This places you in the editing mode. 3. Use the arrow and backspace keys to remove the text currently there. 4. Type in "Total Quantity". Let's see what is there. To switch to the form view, click the View left of the toolbar. button on the far

There is a small problem right now. If you look at the Quantity Received field, there is nothing in there. Without having a value in that field, the Total Quantity field will not appear. Another problem that is once you enter a value in Quantity Received, once you switch to another record, this value carries over. This would be very hazardous in our situation where we are tracking inventory. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

85

We are going to continue to build our Price and Quantity Form. In this section we will: 1. Fix our Quantity Received problem. 2. Add a button to save our record. 3. Add a button that will close the form. Initializing a Field Currently the problem with the Quantity Received field is that there is no value in there when we first view the form. Also, the value we do enter is being cascaded across each record we look at. Here is how we can initialize a field every time you switch to a different record. 1. Click once in the gray non-working part of the window (see below).

2. If the Properties box is not showing already, click the Properties button on the toolbar. 3. Scroll down through the list until you come to "On Current". This control is executed every time you switch to a different record. 4. Click once on the On Change box and click the button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

86

5. The following window appears:

Click Code Builder from the list and click the OK button. 6. The Class Module window appears. This is the area where you do the programming in.

7. Type in: [Quantity Received] = 0. This will reset the field every time the record is changed. 8. Close the Class Module window by clicking the button in the window.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

87

Switch to the Form View and see what happens.

As you can see, the value 0 appears in the Quantity Received field and now the Total Quantity field can be calculated and has a number in it.

Adding a "Save" button We are now going to add a button to save the changes we do to the record. 1. 2. 3. 4. In the Toolbox, click the button. The mouse pointer will change to . Click once just below the Retail Price field. The Button Wizard will begin. The first step allows you to pick the type of action to be performed when the button is clicked. In the Categories section, click Record Operations. In the Actions section, click Save Record. Click the Next button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

88

5. This step allows to select if you want a picture in your button or text. Click the Text option. Click the Next button.

6. This step allows you to assign a name for the button. This Name field you will find in the Properties window. Type in "Save Button" and click the Finish button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

89

This button will now save any changes that have been made (Cost Price). But what about Total Cost. This field is not a field in our table. This new value has to be assigned QuantityInStock to have correct numbers. 1. Click the Save Button object. 2. If the Properties box is not showing already, click the Properties button on the toolbar. 3. Scroll down through the list until you come to "On Click". 4. Click once on the On Change box and click the button. 5. You should see some code there already. Access has automatically generated this code as you were using the Button Wizard. Click the line above the "DoCmd......" line. Type in: [QuantityInStock] = [QuantityReceived] = 0 [TotalQuantity] <press return key>

This will assign the new value to QuantityInStock before the record is saved and initialize the QuantityReceived field. 6. Close the Class Module window by clicking the Adding a "Close" button We are now going to add a button to save the changes we do to the record. 1. In the Toolbox, click the button. The mouse pointer will change to 2. Click once just below the Total Quantity field. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT . button in the window.

90

3. The Button Wizard will begin. 4. The first step allows you to pick the type of action to be performed when the button is clicked. In the Categories section, click Form Operations. In the Actions section, click Close Form. Click the Next button.

5. This step allows to select if you want a picture in your button or text. Click the Text option. Click the Next button.

6. This step allows you to assign a name for the button. This Name field you will find in the Properties window. Type in "Save Button" and click the Finish button. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

91

You now have a button to close the form.

Linking the Forms Together


Now that we have these two forms, let's link them together. The goal here is once the user selects a product from the List Box, they will click a button and the Price and Quantity form will open. Opening the Categories Form 1. Click the Forms tab in the main window. 2. From the list show, click Category. 3. Click the Design button. Adding the Price and Quantity Button Now that the form is open, we have to add the button. 1. 2. 3. 4. In the Toolbox, click the button. The mouse pointer will change to . Click once to the right of the List box. The Button Wizard will begin. The first step allows you to pick the type of action to be performed when the button is clicked. In the Categories section, click Form Operations. In the Actions section, click Open Form. Click the Next button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

92

5. This step allows you to select which form you want to open when the button is clicked. Click PandQInfo from the list and click the Next button.

6. When the PandQInfo form opens, we only want to see the information for the product that was selected in the List Box. Click the "Open the form and find specific data to display. Click the Next button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

93

7. In this step, we have to pick the fields in each form that provide the common link between the two. In the Categories section, click ProductSelected. In the PandQInfo section, click ProductName. Click the Next button.

8. This step allows to select if you want a picture in your button or text. Click the Text option and type in "Price and Quantity" in the text box. Click the Next button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

94

9. This step allows you to assign a name for the button. This Name field you will find in the Properties window. Type in "PandQButton" and click the Finish button.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

95

Chapter 10 Working with Reports

In this chapter we will discuss


What Are Reports? Views in Reports The Report Wizards Creat ing Reports fro m Scratch Printing Reports Adding Page Breaks Report Temp lates Sorting Data in Reports Grouping Data Group Headers and Footers Calculating Totals on a Report:

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

97

What Are Reports?

Reports provide ways to retrieve and present selected information stored in your database. You can base a report on a table or query. Reports are designed to be printed rather than viewed only on a computer screen, so they need to be carefully planned to make sure that you use them most effectively and meaningfully. Like queries, reports do not store the data they present. Examples of reports that we use every day are mailing labels, invoices, receipts, sales summaries, and phone books. Since you will be using reports to make presentation quality documents, they need to possess enough design flexibility to allow you to get the right message across to your audience. In Access you can combine text, data, pictures, lines, boxes, graphs, and drawings to design exactly the report you need. You can save the design of a report as a kind of template that you can use over again. Fortunately, Access also comes with several pre-planned report layouts that you can set up in a few minutes using Report Wizards. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

98

Access reports are especially useful if you need to:


Organize and present data in groups Calculate running totals, group totals, grand totals, and percentages of totals Include subreports and graphs Present your data in an attractive format

Views in Reports

In the database window, you have two options through which to open a report: Print Preview and Design Vie w. These are also viewing options when you are inside a report. Preview view allows you to see the report as it will look on the printed page, that is, with actual data culled from the underlying table or query. You can only use this view if you have a printer listed as your default printer for Windows. You cannot make changes to a report in Preview view. Instead, you make changes in Design view. As with forms and tables, Design View, allows you to see how your report is put together and to change its formatting. It gives you access to a full toolbar, the toolbox, rulers, grid, the Properties window, and the status bar. You can move between these two views very easily. In Design View, select the Print Preview icon from the File or Vie w menu (shown above) or click on the same Print Preview icon on the toolbar. From the Print Preview sc reen, select the Design View icon from the View menu (also shown above) or click the Design Vie w icon on the toolbar in order to get back to Design view. Another view for reports is Layout Previe w, which is a modified version of Print Preview. This mode is ideal if you just need to do a quick check for layout features. You should use Print Preview to check the data for the entire report. The icon for Layout Preview is also located on the toolbar as well as in the Vie w menu.
Creating a New Report

Like all Access objects, you create a new report by selecting the New button in the Database Explorer. The New Report window appears and you are then presented with two options: using one of several wizards or designing your own report from scratch by selecting Design Vie w. Note that you can also create a report using Wizards by selecting Create report by using wizard in the Access window. You can also create a report from scratch by selecting Create report in Design view in the Access window. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

99

The Report Wizards

One advantage of wizards is that they perform many basic formatting tasks and allow you to concentrate on refining special features of the report. There are four basic types of Report Wizards:

Report Wizard: This is the most flexible wizard.

This wizard leads you through a series of windows that will help format and stylize your report. It will ask you to select a table or query that your report will be based on. Once a table or query is selected, all the fields from that table or query appear beneath the Available Fields field (shown above). You can select each field that you want to appear in your report by clicking on it and pressing the right arrow button. You can also select all the fields in the table or query by pressing the double right arrow button. Selected fields appear beneath Selected Fields. You can unselect any or all selected fields by pressing either of the left arrow buttons.
Using the Wizard Create a report using Access' wizard by follow ing these steps: 1. Double-click the "Create report by using wizard" option on the Reports Database Window. 2. Select the information source for the report by selecting a table or query from the Tables/Queries drop-down menu. Then, select the fields that should be displayed in the report by transferring them from the Available F ields menu

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

100

to the Selected Fields w indow using the single right arrow button > to move fields one at a time or the double arrow button >> to move all of the fields at once. Click the Next > button to move to the next screen.

3. Select fields from the list that the records should be grouped by and click the right arrow button > to add those fields to the diagram. Use the Priority buttons to change the order of the grouped fields if more than one field is selected. Click Next > to continue.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

101

4. If the records should be sorted, identify a sort orde r here. Select the first field that records should be sorted by and click the A-Z sort button to choose from ascending or descending order. Click Next > to continue.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

102

5. Select a layout and page orientation for the report and click Next >.

6. Select a color and graphics style for the report and click Next.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

103

7. On the final screen, name the report and select to open it in either Print Preview or Design View mode. Click the Finish button to create the report.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

104

Creating Reports from Scratch

To create a record from scratch, click the Reports tab in the Access Window, and then select Create report in Design vie w, or select Design View in the New Report window. What appears is a blank report in Design View upon which controls will be placed.
Anatomy of a Report

Understanding the structure of a report is very important when you design your own reports. Access reports use three nested sections, which you can see by examining a report in Design View (shown above). The three basic sections of a report are:

Report Headers and Foote rs: These sections appear only the beginning and end of a printed report. Reports often display numerous records from an underlying table or query. Each record occupies a page in the report and the user navigates through these pages with the navigation buttons provided by Access at the bottom of the Print Preview screen. The report header will appear only at the top of the first page of the report and the report footer will appear only at the bottom of the final page of the report. Often, the report headers and footers contain labels that describe the overall report. Page Headers and Footers: These appear at the top or bottom of every page in a report. Page headers and footers always stay visible when the user navigates through records in the Print Preview screen. Page headers and footers usually contain labels that provide information concerning each record. Details: This section displays data from either one record or as many records as will fit at once on the screen or page. There is at least one Detail section for each

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

105

record in the underlying table or query. The majority of your controls should be placed in Details. The Details section is always nested between the page headers and footers, and the page headers and footers are always nested between the report headers and footers. You can create or delete page headers and footers as well as report headers and footers in Design view by right-clicking the screen and checking (or unchecking) the appropriate items in the menu that appears. You can also check (or uncheck) Report Header/Footer or Page Header/Footer in the Vie w menu. As with any published document, too much blank paper and not enough information can ruin a good report. Generally, most report sections should be only slightly larger than the information displayed in them. This is why it is important to know how to change the size of sections. To do this, place the mouse pointer on the bottom or right edge of the section you want to adjust. The pointer will change from the standard white arrow to a black, multi-pointed arrow when you are on the edge. Then, drag the edge until the section is the size you want. You can use the rulers at the top and left of the form to size the sections exactly. You can change the height of sections independently, but a report has only one width. When you change the width of a section, you change the width of the e ntire report.
Create in Design Vie w To create a report from scratch, select Design View from the Reports Database Window. 1. Click the Ne w button on the Reports Database Window. Highlight "Design View " and choose the data source of the report from the drop-down menu and click OK.

2. You will be presented with a blank grid with a Field Box and form element toolbar that looks similar to the Design View for forms. Design the report in

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

106

much the same way you would create a form. For example, double -click the title bar of the Field Box to add all of the fields to the report at once. Then, use the handles on the elements to resize them, move them to different locations, and modify the look of the report by using options on the formatting toolbar. Click the Print View button at the top, left corner of the screen to preview the report.

Printing Reports Select File|Page Setup to modify the page margins, size, orientation, and column setup. After all changes have been made, print the report by selecting File|Print from the menu bar or click the Print button on the toolbar. Reviewing Control s

Reports and forms use the same controls. There are three basic types of controls: bound, unbound, and calculated. Bound controls are those whose source of data is a field in a table or query in your database. A text box is the most common type of bo und control. As the user navigates through the records on which a report is based, bound controls will display the values in the fields of each record. An unbound control does not have a data source in your database. Unbound controls include labels, lines, rectangles, and pictures and contain values that the database developer provides. These values do not change as Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

107

the user navigates through the records. A calculated control is based indirectly on an underlying table or query in that its data source is an expression that is performed on the underlying data. This expression is usually written in the control itself. An example of a calculated control would be an arithmetic operation carried out on a given field or fields, such as: =[Num_FT_Students] + [Num_PT_Students] In this case, the values in two fields in an underlying table or query, Num_FT_Students (which tallies the number of full time students) and Num_PT_Students (which tallies the number of part time students), are added in the calculated control. The controls most often used in Access are:

Labels: These controls contain text entered by the database developer. Labels are most often used to enhance the appearance of a report and are never bound to an underlying table or query. Text boxes: These controls are boxes that contain text. They are most often bound to an underlying table or query. Yes/No Controls: These controls are either check boxes, option buttons, or toggle buttons. These display boolean, or yes/no, values. A check box indicating a "yes" value is a check in a small box; for an option button, it is a dot in a small circle; for a toggle button, it is a pressed button. These controls may be bound to yes/no fields in an underlying table or query. Because reports users do not interact with controls they way they do in forms, toggle buttons (which can be "pressed" in forms) usually do not appear in reports. Line, Box, and Image Controls: These controls enhance the appearance of the report. Line and box controls allow the developer to partition information on the report. Image controls allow the developer to place graphics on the report. Drop Down Controls: These controls are list boxes and combo boxes and both can be bound. Both are similar to text boxes except that they can contain a list of entries, not just one. List boxes present the entire list, often with scrollbars when the list is longer than the listbox itself. Combo boxes present only one list item at a time. Since combo boxes require user interaction, they also do not usually appear in reports. Further, if list boxes are to be used in a report, they should be large enough to contain an entire list without having to use scrollbars.

One important reminder: Since reports are designed for displaying and print information, users cannot interact with controls in reports like they can in forms. This means that users cannot enter or change values presented by controls in a report.
Adding Page Breaks

Using page breaks is a good way to break information into discrete units. If you want to divide the information within a report section between two or more pages, you use a page Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

108

break control to mark where you want the new page to begin. Below is the page break icon as it appears on the toolbox.

In Design view, the page break control appears as a dotted line. In Print Preview, however, everything above the control in the section appears on one page and everything below it in the section appears on the following page. If you want to force a page break after or before a particular section of your report, go to Design view and select the section by clicking on the bar above it. The bar will become black to indicate that the section is selected. Then click the field next to the Force New Page property under the Format tab in the Properties window. A drop down menu then appears and you can select where the new page will appear.

Report Templates

Like many word processors, Access's report fo rmatting options allow you to create a template to use for other reports. When you create any new report from scratch (that is, without the Report Wizard) either by pressing Design Vie w in the New Report window or Create report in Design vie w in the Access window, Access uses a default template to determine the report's initial characteristics, namely, which sections the report will contain and where on the page they will appear. The default Access report template is called Normal. If you design a report that you want to use as a template for other reports inside the same database, you can change the default template name from Normal to the name of the report you want to use. You can also create a blank report to use just as a template. Creating a Report Te mplate: 1. Make sure that the report whose characteristics you want to store in the new template is open and its window selected. 2. Choose Options from the Tools menu. 3. Select the Forms /Reports tab. 4. Under Report Template enter the name of the report you have open. 5. Press Apply or OK. At this point, nothing will be changed. However, the next time you create a report from scratch, the new report will use the template you just saved. This means that all new reports will contain sections proportioned exactly how the sections were proportioned in the original report. This includes only the report header and footer, the page header and footer, and the details section. New sections created by you in the original report will not appear in the new one.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

109

Note that a report based on a template will still be empty. Creating a template does not include the controls that were on the original report. Note also that Access does not default back to Normal, even if you close the application. This, or the entry of any new template, must be done manually.
Sorting Data in Reports

When creating a report, you will often need to arrange the data in a particular order. For example, if you are printing out a mailing list, you might want to sort the names alphabetically or to sort them by increasing Zip Code. You use the Sorting and Grouping window to establish the sort order. You open this window by selecting Sorting and Grouping in the Viewmenu or by selecting the Sorting and Grouping icon from the toolbar (shown below).

You use the top part of the window to set the sort order for the records in a report. You can sort up to ten fields and expressions, and you can sort on the same field or expression more than once. Field/Expression specifies the name of the field or expression on which to sort. The order of sorting for the report goes down the column. Sort Order tells Access how to sort the data in the report. You can choose to sort in either ascending or descending order. In Access, there is no easy way to specify sort orders other than these two kinds.
Grouping Data

The other part of the Sorting and Grouping window is Group Properties. This feature allows you to divide data into groups. A group consists of a collection of records that share a common piece of data, along with any introductory and summary information displayed along with the records. A group consists of a group header, nested groups (if you have any), detail records, and an optional group footer. Grouping gives you a formatting advantage by allowing you to separate groups of records visually, and display introductory and summary information for each group. You might, for example, want to Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

110

group a company's sales by date and then calculate the total sales for each day. You can group on any fields and expressions you sort on, up to 10. When you group on more than one field or expression, Access nests the groups according to their position in the sort order. The first field that you are sorting on should be the first and most significant group level. The second field you group on should be the next grouping level, and so on. This is, in fact, how you create new sections in Access. Group Headers and Footers When you specify sort fields in the Sorting and Grouping window, you actually create groups by adding group headers and footers. After selecting the field that you want to group on, you can set the Group Header and Group Footer properties in the Group Properties part of the box. When you add a header or footer by choosing "Yes" in either of the property boxes, Access places a grouping icon next to the field or expression. You then complete the group by adding the controls you want to appear in the group header or footer in the Design view. Setting Grouping Ranges and Intervals To specify the value or range of values that begin and end a particular group, you use the Group On and Group Interval properties in the Sorting and Grouping window. These properties work hand in hand. First, you select the group field in the Field/Expression part of the window, then you can set the Sort O n and Group Interval properties. When you group records on a text field from an underlying table or query, you have two options for setting the Group On property: Each Value and Prefix Characte rs. Each Value allows you to group records containing the same value in the field or expression, Prefix Characters allows you to group on records with the same first n characters. When you group records on a date field from an underlying table or query, you have many options for the Group On property: Each Value and Year, Qtr, Month, Day, Hour, and Minute. Each Value is the same as above, and the date values allow you to group on records according to certain dates or times. When you group records on an autonumber, currency, or number field from an underlying table or query, you again have two options for the Group On property: Each Value and Interval. Each Value is the same as above, and the Interval value allows you to group values on intervals you specify.
Using Some Common Expressions in Reports

You use expressions to get information that you cannot get directly from the tables in a database. Most calculated controls will use an expression. An expression might calculate and display the total sales of an employee for one month. The result of an expression is not stored, but is calculated each time the report is printed or previewed. People often use text boxes to calculate values, but almost any control that has a Control Source property Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

111

can be used. Two common expressions used in reports calculate the current date and page numbers. Printing the Current Date: There are two Access functions that allow you to calculate the current date: Now and Date. Now gives the current date and time as it is stored in your computer (many computers can lose as much as three minutes each day!). Date() yields only the current date. You can format the result of either of these functions by changing the control's Format property (found in the properties window under the Format tab). To add either of these functions, select the control that you want to contain the date, then enter =Now or =Date() into the control itself or in the control's Control Source property (under the Data tab in the Properties window). The current date will appear in the control whenever the report is printed or viewed on the Print Preview screen. Adding Page Numbe rs: When you print a report that is longer than one page, you will probably want to add page numbers. You add page numbers by using the Page function, which automatically numbers the pages when you print or preview the report. You use the Page function in a text box by entering =Page into the control itself or in the control's Control Source property. You can also calculate the total number of pages in the report with the Pages function. These functions can be used together. For example, if you enter ="Page " & [Page] & " of " & [Pages], then you will end up with "Page 1 of 10." Calculating Totals on a Report: Access gives you the ability to calculate totals easily for both individual records, groups of records, and entire datasets. For instance, you could create expressions to calculate both the hours worked by one employee and the hours worked by an entire department. The most common functions used in calculating totals are Sum ( expr ) and Count ( expr ). The expr argument is the name of a field or an expression. You can use field names in the argument for an expression, but not control names. The field name must come from a table or query, including calculated fields in a query. When you calculate totals, the section of the report where you place the control expression determines the total. To calculate a total for a single record, place the calculated text box in the detail section. To calculate a total for a group of records, place the calculated text box in the group header or footer. To calculate a total for an entire dataset, place the calculated text box in the report header or footer. To calculate the number or hours that a given employee worked (based on the field Hours_Worked in the underlying table or query), you would enter =Sum([Hours_Worked]) in a textbox within the detail section. If you then grouped employees by department, you would enter =Sum([Hours_Worked]) in the group footer. Note: when you want to total the values in calculated controls, yo u must repeat the expressions used in the calculated controls in your Sum function. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

112

Assignments: 1. For the Office database prepared in Chapter2, prepare the following report, which has the following: 1. The header of the report should be Office of Accountant General, Salary Report For the month of <<month>> 2. The Report must be Grouped on department. 3. It must display the Name, Id, Section, Designation, and Net Salary of each employee in the details section. 4. The report must find the total salary distributed in each Department. It should also compute the maximum and the average salary of each department. 5. Page Footer of the report should have the page number. 6. Report Footer must have the count of number of employee, about whom the report was generated. 7. Report footer should also have a space for signature. 8. Various section of the report should be separated by lines and must be clearly visible. 2. Prepare a Report which can display, the summary of advance booking in various shows of the day. Use the Cinema database created in the previous chapter.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

113

Chapter 11 Advance Topics in Ms-Access

In this chapter we will discuss


What Is a Macro? The Macro Design Window What Is an Event? Important Events in Access Attaching Macros to Particular Events Using Conditions in Your Macros Using Modules ( brief overview)

What Is a Macro?

A macro is a mini-program which automatically carries out a task or series of tasks for you. Each task that you want Access to perform is called an action, and Access provides a list of 51 actions for you to choose from when creating a macro. When you run the macro, Access carries out the actions in the sequence theyre listed in, using the objects or data that you have specified. For example, you can create a macro to automatically open a table and a form that you frequently use together. This macro would require two actions: one to open the table and a second to open the form. If you were to add data on the form, you could then use another macro to check the data and display an error message (if needed), or to open another form. Any repetitive or routine task you find yourself doing in Access is a good candidate for a macro. Automating routine tasks improves both efficiency and accuracy into your database because a macro performs the task the same way each time. Some common areas where you would use macros include: Making your forms and reports work together. Finding and filtering records automatically. Setting values in controls. Ensuring data accuracy. Setting properties of forms, reports, and controls. Automating data transfers.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

115

The Mac ro Design Window

When you create a macro, you open a new Macro window. Most of the time, you will begin creating a macro by clicking the Macro tab in the Database window and then clicking on the New button. Much like a table's Design view, you use the top half of the Design Window to add actions and comments to the macro and the lower half of the window to better define the Arguments (or Properties) of the action. You can add comments when you design the macro to explain the reasoning behind each action or to tell which objects are being operated on. Access will simply ignore the comments when running the macro, but they are very helpful when you have to debug the macro to figure out why something is not working properly.
Building a Macro

There are two ways to begin adding actions to your macros: selecting actions from the action list and dragging and dropping. To do the former, click on the first empty cell in the Action column. Then, either select the action you want from the list that appears when you click on the down arrow at the column's right edge or type the action into the box. Then you will need to add the appropriate arguments for the action. You could then enter a comment in the Comme nt column to complete the step. To add an action by dragging and dropping, make sure that both the Macro Design window and the Database window are visible. Then, click the button for the type of object you want to drag in the Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

116

Database window and drag the object from the Database window to an action row in the Macro window. If you drag a table, query, form, or report to the Macro window, Access adds an action that opens the object. If you drag a macro, then Access adds an action that runs the macro
Setting Arguments

Most actions have arguments that give Access necessary information to carry out the action, such as which object to use or open. For instance, the OpenTable action has a Table Name argument that tells Access which table in the database to open. After you add an action, you set the arguments for that action in the lower half of the window by typing in the arguments or selecting them from drop down lists in some instances. If you added the action to the macro by dragging and dropping, then many of the arguments will already be set; however, you should always check them anyway. Many actions have an argument that calls for the name of a database object. You can use a similar drag and drop technique to set these and other arguments. Simply drag the object from the Database window to the lower portion of the Macro window and drop it on the argument you wish to set. You can also type the object's name into the cell; however, the expression builder is often the best way to define an argument.
Saving a Macro

You have to save the macro before you can run it. By saving the macro, you define it as an object that can be opened or run from the Database window. To save a macro, choose Save from the File menu or the Macro toolbar. If you're saving the macro for the first time, enter a name for the macro and choose OK.
Debugging a Mac ro

Most macros are not going to run perfectly the first time you try them. The more complicated the task that you need the macro to perform, the greater the likelihood of something going awry. The easiest way to debug or check out your macro is to step through it one step at a time. You can activate this feature by clicking on the Single Step button on the Macros toolbar. When you run the macro, you will be prompted before the macro proceeds to the next step. If there is an error, you will need to decide whether you want to terminate the macro or to move ahead to the next step anyway.
Running a Macro

You can run a macro from several places in your database, even in response to an event that occurs in a form or report. To run a macro from the Macro window, choose Run from the Macro menu or from the Macro toolbar. To run a macro from the Database window, click the Macro button and then double click on the macro you wish to run. To run a macro from other windows in your database, choose Run Macro from the File menu and type the name of the macro you wish to run in the dialog box. Then, choose OK to run the macro. To run a macro from inside another macro, add the RunMacro Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

117

action to your macro and set the Macro Name argument to the name of the desired macro.
Macros on Form s and Reports: Event -Driven Applications

You can also set a macro to run automatically in response to an event on a form or report by setting the appropriate event property to the name of the macro. For example, you could run a macro automatically when a form is opened or when a command button is pressed. You could also set up a macro to run just before you exit a control to make sure the value entered in a field is allowed.
What Is an Event?

When you use a form or report, Access recognizes certain things that happen on the form as events. For example, moving from one control to another is an event, as is doubleclicking on a control. You can use a macro to respond to any event. Each form and control event has a corresponding event property. You specify how the form responds to the event by using a macro or a module. All you have to do to set the event property to a particular macro is type the macros name in the event property cell.
Important Events in Access

There are six main types of events in Access: Window events, Data events, Focus events, Keyboard events, Mouse events, and Error and Timing Events. Window events occur when you open, resize, or close a form and include the OnOpen, OnResize, and OnClose properties. These events take place exactly when their names imply that they should. Data events occur when data is entered, deleted, or changed in a form or a control, or when the focus moves to another record. Data events include OnCurrent, which occurs when the form is opened and when you move to another record, OnDelete, which occurs when a record is deleted but before the deletion is confirmed and actually performed, and BeforeUpdate, which occurs before a control or record is updated with changed data. Focus events occur when a form or control loses or gains the focus, or becomes active or inactive. In Access, a control gains the focus when you move to it and the cursor flashes inside it (only text and combo boxes). When you leave the original control to move to a new one, the following event sequence takes place (event properties will follow in parentheses). You hit <Tab>, the control is exited (OnExit), the control loses the focus (OnLostFocus), the new control is entered (OnEnter), the new control gets the focus (OnGotFocus), and the cursor tells you the control is now active. These events are good places to put validation checks or programmed lists based on other values. Keyboard events occur when you type on the keyboard or when keystrokes are sent using the SendKeys macro action. Mouse events occur when a mouse action, such as pressing down or clicking a mouse button occurs. OnClick and OnDblClick are the most useful mouse properties to use, especially when you want to move between two forms linked by a common value. Error and Timing events are used for error handling and synchronizing data refreshing on forms (necessary for a multi- user database). The best discussion that I have seen on event ordering in Access is the QUE book on Access, though the manual does a fine job in its own right. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

118

Attaching Macros to Particular Events

To create a response to an event, you must first identify the form or control event that you want the macro to respond to. Then, you write a macro which contains all the actions you want carried out when the event occurs. Finally, set the event property to the name of the macro. You can use the Macro Builder, which is available for each event property, to create a macro and set the event property automatically. To use the builder for creating a macro and specifying it for a property, open the form in Design view and display the property sheet by clicking on the Properties button on the toolbar. Then, select the form or control. In the property sheet, click the event property you want to respond to and then click the Build button immediately to the right of the property box. In the Choose Builde r dialog box, select the Macro Builde r and choose OK. Type a name for the new macro you want to create and again choose OK. When the Macro window appears, enter the actions you want to be carried out and then choose Close from the File menu. Save the changes to the macro when you are prompted, and when the event occur s on the form your macro will run.
Using Conditions in Your Macros

Unfortunately, not all macros are perfectly straightforward. Most of the time, you can set up a macro so that every action entered can and should be executed. Sometimes, however, that simply is not the case because you may need to control or limit macro actions based on a value in a particular field or control. For instance, you can design a form that automatically fills in several field values when a particular value is entered in the first field on the form, making data entry automatic and relatively error-free. In order to make this happen, you will need to set up a macro that checks to make sure that certain conditions are met. For instance, you might set up a record collection database with a macro to insure that anytime the Artist Last Name field value equals Beatles then the Label field value will automatically be set to Apple. All of the macros that you have built so far have two key points in common: 1. All of the actions entered into these macros are executed. These macros end after the last instruction is carried out. 2. The instructions are executed in the order they were entered into the macro.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

119

Once you start using conditions in your macros, however, you will need more co ntrol to make a macro specific enough to be useful. What happens if the Artist Last Name does not equal Beatles or the value in that field is changed to something else? A simple macro does not really account for this kind of situation. We need a more complicated macro, something that corresponds to an If ... Then ... Else loop in computer programming (as in the Access Basic modules that work behind the scenes in Access). Access macros have to provide for the same situation in a more roundabout manner, involving four separate guidelines: 1. Macro conditions and actions are evaluated in the order in which they are entered, starting with the first row in the macro sheet. 2. Once started, a macro terminates when Access encounters a blank row (no conditions or actions, usually the end of the macro) or when the StopMacro action is executed. 3. If a condition is false, the macro skips the action on that line and moves to the next line of the macro sheet. 4. You can link a series of actions to a single condition by placing an ellipsis (...) in the Condition column. The logical structures available for macros are all based on these rules. You need to use all of them to solve even simple problems with an Access macro.
Executing Macros When You Load a Database

One of the most common tasks that many database builders want to do is make their database easy for people to navigate and work in. Most users (especially people doing data entry) have neither the time nor inclination to learn how Access works in order to do Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

120

their jobs, so you must make it easy for them whenever possible. Frequently, you will want to hide the database window/explorer and replace it with a switchboard form that takes your users to where they need to go. The questions should be: What actions do I need to execute to hide the database window and load the form? followed by How do I make this execute automatically on startup? The actions are pretty straightforward. You need to carry out two actions: hiding the database window and opening the form. Hiding any window in Access is accomplished through the Window menu, so you will need to use the DoMenuItem action with the appropriate arguments. Opening the form is carried out with the OpenForm action, specifying the appropriate form name in the arguments. The second part of this problem is making the database open the macro automatically on startup. In order for this to occur, you simply name the macro AutoExec when you save it. This name enables Access to recognize and load the macro when you open the database.
Using Modules (bri ef overview)

Most of the time, you will be able to use macros to do anything you need to do; however, there are occasions when you need something a little more powerful to solve a really complex problem. Almost every time, creating a module in Access Basic will be your path of last resort, but you need to know that it's there. Access Basic is the programming language for Access. You use it very much as you use macros, attaching it to specific event properties. The difference is that Access Basic provides more power and greater control than you get using macros alone. Access Basic is a modern programming language that is based on the increasingly popular Visual Basic. It closely resembles most of the popular, structured programming languages such as Pascal and C by offering all the program structures that they provide. Most importantly, Access Basic retains the English- like feel of all Basic languages. Still, you probably will not want to venture into Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

121

Access Basic if you have never programmed before. It can be quite complex when you start manipulating data in the database.
What is a Module?

You store your Access Basic code in units/objects called modules, which provide a way of organizing your Access Basic procedures. Your database can contain two kinds of modules: Form or Report Modules and Global Modules. The former type is local to a single form or report in your database. Each form in a database has a built- in form or report module that contains event procedures that occur on the form or report. These modules are part of the object's design, so if you copy a form or report to another database, the underlying go will tag along. Global modules, on the other hand, are created as separate objects in your database. You use Global modules to store code that you want executed from anywhere in the database (such as functions that you want to calculate which are not part of the standard function list).
When to Use Modules

The most common reasons to use Access Basic instead of macros are: They make your application easier to maintain because macros are separate objects from the forms and reports that use them, an application containing a lot of macros that respond to events on forms and reports and gets unwieldy. By using Access Basic to respond to events, the code is built into the form or report's definition, and if you move a form to another database the code goes along while macros remain behind. You can create your own functions . While Access contains many functions, Access Basic gives you the ability to create your own without needing to create many complicated expressions. They mask error messages . When something unexpected happens, and it will, Access displays an error message. If your users don't use Access regularly, they will probably either panic or ignore the message. Access Basis allows you to create an internal response to the error and explain it better to your users. Creating or manipulating objects . In most cases, it's easier to do this in the object's Design window; however, in some situations, you might want to manipulate the object in code (especially if you come to Access from DBase or Paradox). Manipulating records one at a time . You can use Access Basic to step through a recordset one record at a time and perform an operation on each record. Macros, in contrast, work with entire recordsets at once.

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

122

Appendix 1 Keyboard shortcuts


Keyboard shortcuts can save time and the effort of constantly switching from the keyboard to the mouse to execute simple commands. Print this list of Access keyboard shortcuts and keep it by your computer for a quick reference. Note: A plus sign indicates that the keys need to be pressed at the same time.
Action Doc ument actions Open existing database Open a new database Save Print CTRL+0 CTRL+N CTRL+S CTRL+P Keystroke Action Select all Copy Cut Paste Undo Redo Bold Italics Left justified Center justif ied Right justified Decrease indent Increase indent Editing Toggle between editing F2 and navigation mode function key Open w indow for editing SHIFT +F2 large content fields Switch from current field ESC to current record Move to record Other Insert line memo field break in a CTRL+ENTER CTRL+; CTRL+: next field in TAB Editing NOT ACCESS Find Replace Insert hyperlink Spell checker Macros CTRL+F CTRL+H CTRL+K F7 ALT +F8 Keystroke CTRL+A CTRL+C CTRL+X CTRL+V CTRL+Z CTRL+Y CTRL+B CTRL+I CTRL+L CTRL+E CTRL+R CTRL+SHIFT +M CTRL+M

Formatting NOT ACCESS

Undo data changes made ESC in current field Display database window Find and Replace Copy Cut Paste Undo F11 CTRL+F CTRL+C CTRL+X CTRL+V CTRL+Z

Moving through a datasheet Next field Previous field First field of record Last field of record Next record Previous record TAB SHIFT +TAB HOME END DOWN ARROW UP ARROW

Insert current date Insert current time

Copy data from previous CTRL+' record Add a record Delete a record CTRL++ CTRL+-

First field of first record CTRL+HOME Last field of last record CTRL+END

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

123

Glossary
Microsoft Access is an entry- level database that offers a flexible environment for database developers and users. It makes use of the familiar Microsoft Office interface and allows for integration with larger-scale enterprise databases such as Microsoft's SQL Server and Oracle. Also Known As: Access, MS Access Attribute A single data item related to a database object. The database schema associates one or more attributes with each database entity. Also Known As: field, column Column Database tables are composed of individual columns corresponding to the attributes of the object. Database is a collection of information organized into interrelated tables of data and specifications of data objects. Entity-Relationship Diagram is a specialized graphic that illustrates the interrelationships between entities in a database. Also Known As: ER Diagram, E-R Diagram, entityrelationship model Foreign Key is a field in a relational table that matches the primary key column of another table. The foreign key can be used to cross-reference tables. Functional Dependency occurs when one attribute in a relation uniquely determines another attribute. This can be written A -> B which would be the same as stating "B is functionally dependent upon A." Index is a database feature used for locating data quickly within a table. Indexes are defined by selecting a set of commonly searched attribute(s) on a table and using the appropriate platform-specific mechanism to create an index INSERT SQL command is used to add records to a table within a database. JOIN The SQL JOIN statement is used to combine the data contained in two relational database tables based upon a common attribute Key A database key is a attribute utilized to sort and/or identify data in some manner. Each table has a primary key which uniquely identifies records. Foriegn keys are utilized to cross-reference data between relational tables Locks Database management systems utilize locks to provide concurrency control. Common uses of locks are to ensure that only one user can modify a record at a time and that data can not be read while it is being modified. Locking mechanisms can be enforced at the row, table or page level. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

124

Metadata is literally "data about data." This term refers to information about data itself -perhaps the origin, size, formatting or other characteristics of a data item. In the database field, metadata is essential to understanding and interpreting the contents of a data warehouse. Normalization is the process of structuring relational database schema such that most ambiguity is removed. The stages of normalization are referred to as normal forms a nd progress from the least restrictive (First Normal Form) through the most restrictive (Fifth Normal Form). Generally, most database designers do not attempt to implement anything higher than Third Normal Form or Boyce-Codd Normal Form. NULL SQL keyword is used to represent either a missing value or a value that is not applicable in a relational table. Oracle is a powerful relational database management system that offers a large feature set. Along with Microsoft SQL Server, Oracle is widely regarded as one of the two most popular full- featured database systems on the market today. Primary Key of a relational table uniquely identifies each record in the table. It can either be a normal attribute that is guaranteed to be unique (such as Social Security Number in a table with no more than one record per person) or it can be generated by the DBMS (such as a globally unique identifier, or GUID, in Microsoft SQL Server). Queries are the primary mechanism for retrieving information from a database and consist of questions presented to the database in a predefined format. Many database management systems use the Structured Query Language (SQL) standard query format. Record A database record consists of one set of tuples for a given relational table. In a relational database, records correspond to rows in each table. Report A database report presents information retrieved from a table or query in a preformatted, attractive manner. ROLLBACK statement in SQL cancels the proposed changes in a pending database transaction. The transaction can be rolled back completely by specifying the transaction name in the ROLLBACK statement. A partial rollback can also be accomplished by specifying a savepoint name in lieu of the transaction name. The alternative to rolling back a transaction is to utilize the COMMIT command to make the proposed changes part of the relational database. Row In a relational database, a row consists of one set of attributes (or one tuple) corresponding to one instance of the entity that a table schema describes. SELECT statement in SQL is the primary mechanism for retrieving information from a relational database. Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

125

Structured Query Language is an industry-standard language used for manipulation of data in a relational database. The major SQL commands of interest to database users are SELECT, INSERT, JOIN and UPDATE. Table in a relational database is a predefined format of rows and columns that define an entity. Transactions are a group of database commands which are to be treated as a single atomic event. Transactions are maintained using the two phase commit system. Tuple is a term from set theory which refers to a collection of one or more attributes

Mohammad Abdul Raheem, System Administrator/IT Support O/o the A.G.(A&E) - RAJKOT

126

Вам также может понравиться