Ms Access(Advanced)

Embed Size (px)

Citation preview

  • 7/27/2019 Ms Access(Advanced)

    1/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 1

    Table of Contents

    1. INTRODUCTION TO MICROSOFT ACCESS

    2. CREATING A DATABASE

    3. PRIMARY KEYS AND INDEXING DATA

    4. IMPORTING A SPREAD SHEET INTO ACCESS

    5. CREATING QUERIES USING MICROSOFT ACCESS

    6. ADVANCE QUERIES

    7. WORKING WITH FORMS

    8. ADVANCE FORMS

    9. WORKING EXAMPLE OF FORMS

    10. WORKING WITH REPORTS

    11. ADVANCE TOPICS IN MS-ACCESS

    12. APPENDIX

    13. KEYBOARD SHORTCUTS

    14. GLOSSORY

  • 7/27/2019 Ms Access(Advanced)

    2/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 2

    Chapter 1

    Introduction to Microsoft Access

    Todays era as we all know referred to as an era of Information technology. Informationis the key to decision making. Large business firms maintain huge databases to deriveinformation of various sorts to facilitate their decision-making bodies to prepare perfectstrategies. Information is closely related to data, which is the root base of all theoperations. Before we proceed further lets see what are the basic terms Data andInformation 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 bedrawn i.e. we interpret the raw data to derive something meaningful. Data is always inhuge 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 processingthe huge or bulky data. It is in a very condensed and symmetric form and help indecision-making.

    Database DefinedA 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 adictionary where words are arranged alphabetically, or telephone directory wheresubscriber names are listed in an alphabetically.

    What is Database Management System (DBMS)?A database Management system is essentially a collection of interrelated data anda set of programs to access this data. This collection of data is called theDatabase. The primary objective of DBMS is to provide a convenientenvironment to retrieve and store database information. Database system supportsingle-user and multi-user environment.

    In this chapter we will discuss Database Defined What is Database Management System

    (DBMS)? Tasks of DBMS: Microsoft Access Description

  • 7/27/2019 Ms Access(Advanced)

    3/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 3

    A Database System consists of two parts namely: Database Management System and Database Application . Database Management System is the program thatorganizes 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. Acharacter is the smallest piece of information in a database. It cannot be brokendown further into parts.

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

    AttributesAn attribute is the characteristics property of an existing entity. The difference

    between attribute type and attr ibute instance has to be understood. Attribute typeis the property of entity type, and attribute is the property of entity instance. The

    terms data items, data e lements, data fields, items, elementary items, or object property also refers an attribute.

    Attributes valuesEach attribute of an entity set has a particular value. The set of all possible valuesthat a given attribute can have are called its domain.

    Entity Set Attribute ValueEMPLOYEE Name Mr. Pramod Gour

    Ration card No 12-2000-12-67-21Address 63, Ward No-2, Amber Skill Computer ProfessionalAnnual salary 15,20,000

  • 7/27/2019 Ms Access(Advanced)

    4/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 4

    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 allinformation about one particular item. For examples in an employee database allinformation about the employee like name, address, designation, salary, dept

    _name are recorded.

    Data Manipulation: Allows data in the Database to be inserted, updated, deletedand 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 meaningfulinformation 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. Creating of files (dec iding the fields, their types & sizes)2. Adding a new record to a database3. Rearranging record into some meaning order.4. Searching a record in a database to find a specific piece of information5. Printing data from database to get a formatted report.6. Editing a record in a database.7. Deleting a record from a database.

  • 7/27/2019 Ms Access(Advanced)

    5/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 5

    Microsoft Access Description

    Microsoft Access is a Database Program. Access is a Relational Databasemanagement system. Microsoft Access is a powerful program to create and manageyour databases. The data contained in a database is viewed as a set of two-dimensional tables that present the data in rows and columns. You can builtrelationship between tables that contain different fields to put together reports thatdraw form a number of different tables and thus display the information you need tosee. 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 databaseapplication than other programs such as Microsoft Works.

    This reading material will help you get started with Microsoft Access and may solvesome of your problems, but it is a very good idea to use the Help Files that come withMicrosoft Access, or go to Microsoft's web site located athttp://microsoft.com/office/access/default.htm for further assistance.

    Using Microsoft Access, you can manage all your information from a single databasefile. 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 enginemanages the data.

    For example, suppose the phone numbers of your suppliers are stored in variouslocations: in a card file containing supplier phone numbers, in product informationfiles 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 thesupplier'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 adatabase.

    http://microsoft.com/office/access/default.htmhttp://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecGetStartedWithAccess97.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecGetStartedWithAccess97.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecGetStartedWithAccess97.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecGetStartedWithAccess97.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecGetStartedWithAccess97.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecGetStartedWithAccess97.htm%23%23http://microsoft.com/office/access/default.htm
  • 7/27/2019 Ms Access(Advanced)

    6/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 6

    Database File: This is your main file thatencompasses the entire database and that is saved toyour hard-drive or floppy disk.Example) StudentDatabase.mdb

    Table: A table is a collection of data about a specifictopic. There can be multiple tables in a database.Example #1) StudentsExample #2) Teachers

    Field: Fields are the different categories within aTable. Tables usually contain multiple fields.Example #1) Student LastNameExample #2) Student FirstName

    Datatypes: Datatypes are the properties of each field.A field only has 1 datatype.FieldName) Student LastNameDatatype) Text

    A table is a collection of data about a specific topic, such as products or suppliers. Usinga separate table for each topic means that you store that data only once. This results in amore 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 theinformation about one product, such as the product's name, supplier ID number, units instock, and so on.

  • 7/27/2019 Ms Access(Advanced)

    7/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 7

    Chapter 2

    Creating a Database

    As seen in the earlier chapter the key factor any relational database management systemare databases, which are themselves collection of tables. So the first step in to start withMs-Access is to create a database. Access provide two method to create a database- onecreating 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 aBlank Database to create a database.

    About designing a database

    Good database design ensures that your database is easy to maintain. You store data intables 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 changeautomatically appears throughout the database.

    A well-designed database usually contains different types of queries that show theinformation you need. A query might show a subset of data, such as all customers inLondon, or combinations of data from different tables, such as order informationcombined 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 andthey would like the database to answer.

    Sketch out the reports you'd like the database to produce.

    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

    http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23
  • 7/27/2019 Ms Access(Advanced)

    8/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 8

    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 beginto emerge. From that, you can determine what facts you need to store in the databaseand 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 storethe 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. Whendetermining 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, ina Suppliers table, if you create a Products field that contains a comma-separatedlist of each product you receive from the supplier, it will be more difficult to findonly 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 anadditional 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 difficultto 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 Productstable 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, itssubject is an employee, so it belongs in the Employees table. You might have a tablefor Customers, a table for Products, and a table for Orders.

    Determine which table each field belongs toWhen you decide which table each field belongs to, keep these design principles inmind: 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 alot of duplicate information, that field is probably in the wrong table.

    http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23
  • 7/27/2019 Ms Access(Advanced)

    9/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 9

    For example, if you put the field containing the address of a customer in theOrders table, that information will probably be repeated in more than one record,

    because the customer will probably p lace more than one order. However, if you put the address field in the Customers table, it will appear only once. In thisrespect, 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 entriesthat 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 inyour 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 keyfields, 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-designeddatabase such as the Northwind sample database.

    http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconDesignDatabase.htm%23%23
  • 7/27/2019 Ms Access(Advanced)

    10/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 10

    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 anew 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, etcnecessary for the database.

    Selecting Open an Existing Database allow you to open a database that has been alreadycreated. The bottom part of the window will list the most recent databases that have beenused. To open one, double click the file name or click the file name once and click theOK button. If the file is not in the list, double c lick "More Files . . ." and the Open dialogwindow will open allowing you to switch to appropriate drive and directory where thedatabase is stored.

    We are going to select Blank Database and click the OK button.

  • 7/27/2019 Ms Access(Advanced)

    11/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 11

    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 endsin "(:)".

    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 youautomatically)

    3. Click the OK button.

    The database has now been created in the C: drive. The main window for Access shouldnow be showing.

    Tip:Even though you have not done anything with your database yet, a new file has beencreated. This means if you decided that you did not want to continue with thisdatabase, you should go in to the Windows Explorer and delete the market.mdb file.

  • 7/27/2019 Ms Access(Advanced)

    12/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 12

    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 DescriptionDatasheetView

    Places you in the datasheet view with predefined fields. This methodallows for direct data entry in to the table.

    Design ViewAllows you to create the fields necessary, allowing for different options to

    be set (name, data type, etc).Table Wizard Leads you through laid out steps that assist you to develop the new table.

    Import Table Import information in to the database and sets up the database according tothe 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:

  • 7/27/2019 Ms Access(Advanced)

    13/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 13

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

    List of Items on the Screen

    Item DescriptionField Name Name of the field. Can have spaces.

    Data Type Type of data that is to be stored. Can be things like text, numbers, data/time,memo, etc.

    Description A description of the field. This is optional and will show in the status bar when the user is in that field on a form or in the datasheet view.

    PrimaryKey

    Sets the field to be a primary key (ensures that no two records contain thesame value for that field). Generally in file we have fields that help toidentify a record uniquely. The value of these fields do not repeat in anyrecord. 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 Format in which to display the values for the field to the users. (i.e. show a postal code with the space in the middle).DecimalPlaces Set the number of decimal places to show for a numeric field.

    Input Mask Restrict the data that the user can enter. Used to ensure correct data entry.(i.e. for a postal code, you want to make sure that the first character enteredis a letter and not a number.

    Caption If you want a different name to appear for the column header in the

  • 7/27/2019 Ms Access(Advanced)

    14/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 14

    datasheet view or the label in form view. (i.e. originally call field "emp#" but you want the labels to say "Employee Number"

    DefaultValue A value to be entered in to the table if the user does not enter one.

    Validation

    Rule

    Can be used to validate the information the user enters. (i.e. make sure the

    value is always less than 100)ValidationText

    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.

    Required If turned on, the user must enter something in this field in order to save therecord.

    Data Types

    Most of the items above are optional. If you enter nothing in them, your table will stillfunction properly. Something that can not be avoided is selecting a data type. Thisdistinguishes the type of information to be stored in the table.

    Item Description

    Text A character string with a maximum length of 255 characters.

    Memo

    A character string with a maximum length of 64,000 characters. Usuallyused for descriptions of items (i.e. describing a truck would probablyrequire more than 255 characters). A memo field cannot be used as a

    primary key.

    Number

    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).

    AutoNumber Access will automatically generate a number for this field. Usually used asa unique identifier for primary key purposes.

    Yes/No Used to store logical results from True or False results. Be careful as -1stands for Yes and 0 stands for No.

    Date/TimeUsed for storing dates and times. The format can be changed in the Format

    box.

    CurrencyUsed 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.

    OLE ObjectUsed for OLE compliant applications (i.e. linking a portion of aspreadsheet to the table)

    Hyperlink Used for storing web addresses.

  • 7/27/2019 Ms Access(Advanced)

    15/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 15

    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. Tocreate a new field, move to the Field Name in a blank row and type the field name. Eventhough you can have spaces in the name, we will not include any in our field names.

    Field Name Description DataType Other Information

    ProductName Name of the product. Text Field Size of 30

    Category Category product falls in. Text Field Size of 20Distributor Company where we buy the product. Text Field Size of 50

    Cost Price Price we buy product for. CurrencyMarkUp Amount we increase the price fromcost. Number

    Field Size of Single

    QuantityInStock Number of units in stock. Number Field Size of Single

    We want the Product Name to be our primary key as we will never have a product withthe 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 graystub) 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 thetable:

    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.

  • 7/27/2019 Ms Access(Advanced)

    16/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 16

    Close the Table

    To close the table, click the button or se lect File, Close from the menu.

    Entering Values in Table

    In the Access main window, you should see an entry called "Products" under the Tablesection. 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 alist of keys for entering values:

    Key Description

    Tab 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.Shift -Tab

    Moves to the next field to the left. If you are in the first field for the record, itwill move you to the next record above the current record.

    ArrowKeys Moves in the d irection of the key pressed.

    Enter Moves to the next field to the right. If you are in the last field for the record, itwill 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 Tabkey, it will move to the next field to the right, but does not save the record. If you pressthe Up or Down arrow key, this will move to a different record and the changes to thecurrent record will be saved automatically.

  • 7/27/2019 Ms Access(Advanced)

    17/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 17

    Here is a list the entries to enter:

    ProductName Category Distributor Cost Price MarkUp QuantityInStock

    Apples Fruit Eatery Fruits $0.25 0.33 65

    Coke Pop Coca-ColaLtd. $0.93 0.15 64

    Dad's Oatmeal Cookies Dad'sCookies Ltd. $3.47 0.3 22

    Diet Coke Pop Coca-ColaLtd. $0.93 0.15 24

    Diet Pepsi Pop PepsiCo Ltd. $0.88 0.15 33

    Double Fudge Cookies Nabisco Ltd. $2.57 0.22 15

    Fruit Loops Cereal Kellogs Ltd. $3.58 0.25 40HoneyCombs Cereal Post Ltd. $3.14 0.23 33Oranges Fuit Eatery Fruits $0.30 0.25 40Oreo Cookies Christie Ltd. $2.30 0.18 20

    Pepsi Pop PepsiCo Ltd. $0.87 0.15 79Rice Kripsies Cereal Kellogs Ltd. $3.97 0.17 45

    To close the table, click the button or se lect 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

    http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23
  • 7/27/2019 Ms Access(Advanced)

    18/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 18

    field and is included in the Object Definition of the table. The description isoptional.

    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, andthen on the Insert menu, click Column.

    3. Double-click the new column's name, and then type a unique name for thecolumn.

    If you want to customize a field's definition further for example, to change itsdata 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 mustopen 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 tableWhen you delete a field, remember that if other database objects contain references to thedeleted field, you need to delete those references as well. For example, if a reportincludes a control bound to the deleted field, Microsoft Access won't be able to find thedata from the field and will generate a message.

    You can't delete a field that's part of a relationship -you must delete the relationshipfirst.

    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 .

    http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acdecDeletingFieldsS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowAddFieldTableInDatasheetViewS.htm%23%23
  • 7/27/2019 Ms Access(Advanced)

    19/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 19

    Assignments: Based on your above knowledge try to solve the following assignments:

    Prepare a database called- OfficeI. Create the following tables:1. Employee:

    Empid Employee Name DOB AddressCAG/97/01 Amit 23-Dec-1977 Jawahar Nagar CAG/97/02 Vinay 12-Dec-1961 Raja ParkCAG/97/03 Kishori Lal 17-Mar-1963 Adarsh Nagar CAG/97/04 Pramod Gour 18-Oct-1962 AG ColonyCAG/97/05 Vijay Agarwal 19-Oct-1960 AG ColonyCAG/97/06 Nilesh Nathawat 15-Dec-1979 AG ColonyCAG/97/07 Parul Jain 14-Dec-1977 Jawahar Nagar CAG/97/08 Pankaj Jain 18-Oct-1977 Raja ParkCAG/97/09 Vipin Handa 17-Nov-1977 Raja ParkCAG/97/10 Rakesk Arora 18-Nov-1965 AG ColonyCAG/97/11 Harsh Parnami 14-Mar-1972 Adarsh Nagar CAG/97/12 Dilip Kungwani 8-Oct-1980 Jawahar Nagar CAG/97/13 Ritu Jain 9-Oct-1970 AG ColonyCAG/97/14 Priyanka Dheer 1-Dec-1978 Govind Nagar CAG/97/15 Anit Dutt 12-Dec-1963 Jawahar Nagar

    CAG/97/16 Arvind Agarwal 14-Jan-1978 Govind Nagar CAG/97/17 Rakesh Goyal 15-Nov-1978 Raja ParkCAG/97/18 Sunita Goyal 18-Oct-1969 Adarsh Nagar CAG/97/19 Prashant Dixit 15-Dec-1978 AG ColonyCAG/97/20 Govind 12-Dec-1975 Govind Nagar CAG/97/21 Vinay Katyal 12-Dec-96 AG Colony

  • 7/27/2019 Ms Access(Advanced)

    20/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 20

    2. Employee Details: (Primary Key : Empid)

    EmployeeId DOJ Department Section Designation Basic

    ITDeduction Deputation

    CAG/97/01 24-Dec-1999 Railway Audit Report SO 4589 850 YCAG/97/02 12-Dec-1981 Railway Audit CASS AAO 5687 850 NCAG/97/03 17-Mar-1989 P&T Report AO 7698 1000 NCAG/97/04 18-Oct-1987 CAG Report AO 7897 1000 NCAG/97/05 19-Oct-1979 AG Report AO 7847 1000 NCAG/97/06 15-Dec-1999 AG CASS AAO 5689 1000 NCAG/97/07 14-Dec-1999 Railway Audit GD DAG 13545 1200 NCAG/97/08 18-Oct-1999 AG CASS DAG 14597 1200 NCAG/97/09 17-Nov-1999 AG GD SO 4595 850 N

    CAG/97/10 18-Nov-1999 Railway Audit Report DAG 14569 1200 NCAG/97/11 14-Mar-1995 AG Library & Training DAG 12896 1200 YCAG/97/12 8-Oct-1999 Railway Audit Library & Training SO 6987 1000 YCAG/97/13 9-Oct-1995 P&T GD AAO 8956 1200 YCAG/97/14 1-Dec-1999 P&T GD AAO 6987 1000 NCAG/97/15 12-Dec-1987 AG Report CLERK 4698 850 YCAG/97/16 14-Jan-1999 Railway Audit Library & Training CLERK 4896 850 NCAG/97/17 15-Nov-1999 P&T GD CLERK 4489 850 NCAG/97/18 18-Oct-1985 AG GD SO 4698 850 NCAG/97/19 15-Dec-1986 Railway Audit Library & Training AAO 4589 850 NCAG/97/20 12-Dec-1993 Railway Audit Library & Training AAO 7596 1000 YCAG/97/21 12-Dec-97 CAG CASS SO 6598 1000 Y

  • 7/27/2019 Ms Access(Advanced)

    21/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 21

    3. Course: (Primary Key : Nil)Empid CourseCAG/97/01 Oracle DBACAG/97/06 AccessCAG/97/07 IT AuditCAG/97/08 AccessCAG/97/09 DbaseCAG/97/12 InternetCAG/97/14 Oracle DBACAG/97/16 Oracle DBACAG/97/17 Oracle DBACAG/97/19 IT AuditCAG/97/04 InternetCAG/97/05 InternetCAG/97/06 DbaseCAG/97/10 Oracle DBACAG/97/13 DbaseCAG/97/19 BasicCAG/97/03 DbaseCAG/97/06 InternetCAG/97/09 Oracle DBACAG/97/13 Internet

    CAG/97/16 Oracle DBACAG/97/18 AccessCAG/97/19 Oracle DBA

    4. GPF Register: (Primary Key: Empid)

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

  • 7/27/2019 Ms Access(Advanced)

    22/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 22

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

    period.

  • 7/27/2019 Ms Access(Advanced)

    23/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 23

    Chapter 3

    Primary Keys and Indexing Data

    About primary keys

    The power of a relational database system such as Microsoft Access comes from itsability to quickly find and bring together information stored in separate tables usingqueries, 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 calledthe 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. AutoNumber primary keys : An AutoNumber field can be set to automaticallyenter a sequential number as each record is added to the table. Designating such afield 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 Accesswill 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 databasereplication.

    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.

    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

    http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23
  • 7/27/2019 Ms Access(Advanced)

    24/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 24

    If more than 100 records are routinely added between synchronizing replicas,you should use Replication ID for the FieldSize property setting to preventrecords from being assigned the same primary key value in each replica. Note,however, that an AutoNumber field with a Replication ID field size producesa 128-bit value that will require more disk space.

    2. Single-field primary keys: If you have a field that contains unique values such asID numbers or part numbers, you can designate that field as the primary key. Youcan specify a primary key for a field that already contains data as long as that fielddoes not contain duplicate values or Null values.

    3. Multiple-field primary keys : In situations where you can't guarantee theuniqueness of any s ingle field, you may be ab le to designate two or more fields asthe primary key. The most common situation where this arises is in the table usedto 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, socombining the OrderID and ProductID fields produces an appropriate primarykey.

    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, combiningFirstName and LastName fields to produce a primary key is not a good choice,since you may eventually encounter duplication in the combination of these twofields.

    In a multiple-field primary key, field order may be important to you. The fields ina multiple-field primary key are sorted according to their order in table Designview. 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.

    http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowSetChangePrimaryKeyS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowSetChangePrimaryKeyS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowSetChangePrimaryKeyS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowSetChangePrimaryKeyS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowSetChangePrimaryKeyS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowSetChangePrimaryKeyS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatKindPrimaryKeyDoINeedS.htm%23%23
  • 7/27/2019 Ms Access(Advanced)

    25/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 25

    3. Click Primary Key on the toolbar.

    Note If you want the order of the fields in a multiple-field primary key to be differentfrom the order of those fields in the table, click Indexes on the toolbar to display theIndexes window, and then reorder the field names for the index named PrimaryKey.

    About indexing fields and records in an Accessdatabase

    An index helps Microsoft Access find and sort records faster. Access uses indexes in atable as you use an index in a book: to find data, it looks up the location of the data in theindex. You can create indexes based on a single field or on multiple fields. Multiple-fieldindexes enable you to distinguish between records in which the first field may have thesame value.

    Deciding which fields to index

    You'll probably want to index fields you search frequently, fields you sort, or fields thatyou join to fields in other tables in queries. However, indexes can slow down some actionqueries s uch as append queries, when the indexes for many fields need to be updatedwhile performing these operations.

    The primary key of a table is automatically indexed, and you can't index a field whosedata type is OLE Object. For other fields, you should consider indexing a field if all thefollowing 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 anindex for that combination of fields. For example, if you often set criteria for LastNameand 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 firstfield 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.

    http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowSetChangePrimaryKeyS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowSetChangePrimaryKeyS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconAboutIndexesInAccessDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconAboutIndexesInAccessDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconAboutIndexesInAccessDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconAboutIndexesInAccessDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconAboutIndexesInAccessDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconAboutIndexesInAccessDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconAboutIndexesInAccessDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconAboutIndexesInAccessDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconAboutIndexesInAccessDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconAboutIndexesInAccessDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconAboutIndexesInAccessDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconAboutIndexesInAccessDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconAboutIndexesInAccessDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconAboutIndexesInAccessDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconAboutIndexesInAccessDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconAboutIndexesInAccessDatabase.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowSetChangePrimaryKeyS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/achowSetChangePrimaryKeyS.htm%23%23
  • 7/27/2019 Ms Access(Advanced)

    26/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 26

    Create an index to find and sort records faster

    You can create indexes based on a single field or on multiple fields. Multiple-fieldindexes enable you to distinguish between records in which the first field may have thesame 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 youhave selected all the fields you want to include in this index.

    Note The default sort order is Ascending . Select Descending in the Sort Order columnof the Indexes window t o sort the corresponding field's data in descending order.

    http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23http://l/Desi-Develop-Records/Local%20Settings/Temp/Temporary%20Directory%201%20for%20Step%20One1.zip/mk:@MSITStore:C:/Program%20Files/Microsoft%20Office/Office10/1033/acmain10.chm::/html/acconWhatIsIndexWhyDoNeedOneS.htm%23%23
  • 7/27/2019 Ms Access(Advanced)

    27/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 27

    Table Relationships

    To prevent the duplication of information in a database by repeating fields in more thanone table, table relationships can be established to link fields of tables together. Followthe steps be low 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 includein 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 thecorresponding field on the other table and release the mouse button. The EditRelationships 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 toreferential tables if key records in one of the tales is deleted. Check the EnforceReferential Integrity box to ensure that the relationships are valid and that thedata is not accidentally deleted when data is added, edited, or deleted. Click Create to create the link.

  • 7/27/2019 Ms Access(Advanced)

    28/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 28

    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 toview subdatasheets containing matching information from the other table. In theexample below, the student address database and student grade database wererelated and the two can be shown simultaneously using the expand feature. To

  • 7/27/2019 Ms Access(Advanced)

    29/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 29

    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.

  • 7/27/2019 Ms Access(Advanced)

    30/126

  • 7/27/2019 Ms Access(Advanced)

    31/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 31

    Chapter4

    Importing a Spreadsheet into Access

    To prepare a database, the user may have many options. It is not always necessary thatthe 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 likesFoxPro, dbase etc. one of the most common and easy way use to prepare the database isthe use of ms-excel.One the data has been prepared; a user may wish to transport it from one application toanother. This process of shifting objects prepared in one application into another is calledimporting. It is also possible to import tables form one application into Ms-Access. In thefollowing paragraph we will discuss how to transfer or import a spreadsheet created in msexcel 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 menuthat appears.

    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 t e .

  • 7/27/2019 Ms Access(Advanced)

    32/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 32

    Selecting the Data

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

    3. Select the appropriate worksheet. After you select the spreadsheet toimport, you'll be presented with a new screen asking you to select the Worksheetor Named Range that you wish to import. Most likely, you'll want to accept thedefault option of Sheet1, unless you have a more complex Excel fi le. Notice thata preview of the data is provided in the bottom portion of the window. Take thisopportunity to give the data a quick glance to ensure that it looks like the rightdata 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 tocontinue.

  • 7/27/2019 Ms Access(Advanced)

    33/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 33

    4. Specify whether column headings are present. Often, Microsoft Excelusers 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 RowContains 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 Nextbutton to continue. If you were importing data into an existing database, youcould specify the destination table here. Click the Next button to continue.

  • 7/27/2019 Ms Access(Advanced)

    34/126

  • 7/27/2019 Ms Access(Advanced)

    35/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 35

    Chapter 5

    Creating Queries using Microsoft Access

    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 lessthan .80.

    Access has many types of queries you can run, but we will concentrate on the Select1Query. The big advantage Access has is that you build queries through a graphicalinterface. Before when information was to be retrieved from the database, the user had totype in a big line SQL code to get the information. Access avoids this method byallowing you to basically "click and drag" the fields you want to report on. After youselect 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.

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

  • 7/27/2019 Ms Access(Advanced)

    36/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 36

    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 o f query we want, we have to select which tables are goingto 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 savedquery) to select from to build the query. We only have the one table. Click the Productsname 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.

  • 7/27/2019 Ms Access(Advanced)

    37/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 37

    Sel ecting the Fi el ds

    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, asmall down arrow will appear by to the right of the white box. Click the downarrow. 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 a ll the fields in the Product table that can be se lected for the query. To select the field, click and hold the left mouse button on the Categoryfield in the Product table box. While holding the mouse button down, drag themouse on top of a b lank column and release the mouse button.

  • 7/27/2019 Ms Access(Advanced)

    38/126

  • 7/27/2019 Ms Access(Advanced)

    39/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 39

    This is called a dynaset . It is a temporary table that is created and contains the valuesfrom your query. Be careful though as any changes performed to the data will bereflected 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 button or select View, Design View from the menu.

    Sort i ng the Resul ts

    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 theProductName column. A small down arrow will appear to the right of the box. Click thedown arrow and select Ascending from the list.

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

    Showing a F ield

    By default, when you select a field to have in the query, it shows in the dynaset when thequery is run. But, there may be an instance where you may want a field in your query butnot to show up in the query. For example, let us say that someone wants a list of productsthat 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 theProductName and Cost Price, with Cost Price having a criteria of greater than one. If youclick the Show box under the Cost Price column, this would prevent the price from beingdisplayed in the dynaset, but you would only get the products that are more than onedollar showing because of the criteria entered for Cost Price.

  • 7/27/2019 Ms Access(Advanced)

    40/126

    Moha mmad Abdul Raheem, System Admin i str ator/I T Support

    O/o the A.G.(A& E) - RAJKOT 40

    Removi ng a fi eld from th e 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 onceand 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 fromthe me