This action might not be possible to undo. Are you sure you want to continue?
q An Overview of Database Management System E Components of an Information System
One of the most important functions of any computer system is to provide powerful tool for management of Information System of an organization, in which raw data (Transactions as inputs) is processed to produce meaningful information (Reports as output for different levels of management). The processed data is stored in the form of data files usually referred as Databank. This databank becomes one of the sources of knowledge management required for decision support for monitoring various activities as well as strategic planning etc. Thus components of an Information system can be categorized as follows: · · · · Transactions Processing System for processing raw data Management Reporting System to provide relevant reports to various levels of management Decision Support System for management activities like, monitoring & control, decision support and strategic planning etc. Executive Information Systems for senior executives
In the real world environment, Information flow in the organization is horizontal (between various applications) as well as vertical (across hierarchically organized departments / branches etc). Thus in an organization, Information System can be designed at different levels as follows: · · · · Individual Applications Level Department Level Organization Level Intra-organization Level
Training Division, NIC, New Delhi
Efficiency & effectiveness of any Information System very much depends upon the organization of data files in a data bank, and the procedures adopted for data management In this chapter basics of data management will be covered.
E Conventional Approach for Data Management
Conventionally, for each transaction processing application, separate databanks are created, and the data is stored as sequential files, thus making the process of data updating and retrieval very slow. Further, the following problems are also associated with conventional way of storing the data files: 1. Data Redundancy: Since, each application has its own data files, the other users within the department / organization can not have access to these data files. Thus for every application separate data files are maintained, even if they are common. This causes data redundancy, and wastage of storage space. Data Inconsistency: Data redundancy leads to data inconsistency. Data inconsistency means discrepancy in values of data elements in same data files physically stored at different locations. Data Isolation: The data files of common use, can not be made available for sharing, even if desired so. Security: There can not be enforcement of centralized control on data access, as the data files are created / duplicated as per individual applications requirements. The decisions regarding storing the same data at multiple places are taken at various levels by different people, which are usually of ad hoc nature. Access controls planning becomes difficult in such situation. Data Dependency : The coding in applications is very much dependent upon the data files design. Any change in design of data files (say addition of a new field, or deletion of a field) will warrant for changes to be made in the coding of application also, which uses it. .
Training Division, NIC, New Delhi
Lack of enforcement of standards: It is very difficult to enforce standards in data files designs, as centralized view of data files is never available.
E Database Approach
The Database technology allows logical grouping ( the way, the user wants to view it, as per specific needs of an application) of data files associated with different applications in such a way, that the above mentioned problems associated with conventional way of data management are minimized. A database can be defined as follows: Database is a databank, which is managed by a single agency, and it consists of inter-related files, in which data items are organized in such a way that one can have random access to data, as per specific needs of the users. Important terms associated with a database are: Field: It is the smallest unit of data, which can be stored in a database. For example, a student’s name in a university’s database would appear in the field named as “student_name”. Usually the data types in a filed are Numeric, Character string, Date, Memo, Logical, Hyperlink, Picture etc. The field is at times referred as attribute/data element / data item also. These nomenclatures can be used synonymously. Record: It is a collection of related stored fields. A student record may consist of collection of fields like Student’s name, the course taken, the date of birth, contact address and the grade etc. File (Table): It is a collection of different occurrences of same type of stored record. A file is usually referred as a Table also, it describes an entity (something, about which data is to be stored).
Training Division, NIC, New Delhi
which identifies the type location or ordering of the record. The first is a single root or master field. Three types of common Data Models Hierarchical: The hierarchical database model rigidly structures data into an inverted “tree” in which each record contains two elements. 1 The way user wants to view it as per specific needs of the application 4 Training Division. and updating of values of fields corresponding to a record. Network: The network database model creates relationships among data through a linked-list structure in which subordinate records (called members) can be linked to more than one data elements (called an owner). The second is a variable number of subordinate fields. E Types of Data Model (based on logical 1 data structuring) ö 1. there should be at least one common field in two tables. and it always has a unique value. as well as “Library books issue” file. For example. and it is called Foreign key in the second table. Foreign key can have repeated values also. which keeps record of books issues to students. The two files can be linked together by a common field say Student code. which will get reflected in Student file. 2. Foreign Key: For setting relationship between two tables. New Delhi . often called a key. A Student file in a database may be linked to another file say “Library books issue”. Primary Key: Every record in a file usually contains at least one field that uniquely identifies that record for the purpose of data retrieval. NIC. which define the rest of the data within a record.MS-Access Database: A logical grouping of related files would constitute a database. Combination of more that one fields to act as identifier of a record is called Composite Primary Key. This identifier field is called the primary key. Usually that common field is Primary key in one table.
Not all data is naturally hierarchical. In this model. row is equivalent to a record. It has greater query flexibility than hierarchical model. New data and records can be added easily. a table is equivalent to a file. predetermined by administrator.MS-Access 3. Relational: The relational database model is based on the simple concept of flat tables consisting of rows and columns. High flexibility in ad hoc querying. but less than relational model. ö Comparison between the Three Models Advantages Disadvantages Access to data is predefined by exclusively hierarchical relationships. Relational database Conceptual simplicity is its Processing efficiency and speed characteristic. implement. Network database Many more relationships between data elements can be defined. Relations between different tables can be set through common fields. There is no is lower. New Delhi 5 . Training Division. NIC. and each column is equivalent to a field. Model Hierarchical database Searching is fast and efficient. There is greater speed and efficiency than relational database models. Data redundancy can predefined relationships not be eliminated completely. This is the most complicated model to design. among data. and maintain. Limited search/ query flexibility.
MS-Access ö 1. Even the processing of data is done at the centralized location. Centralized: A centralized database has all the related files in one physical location. and its behavior). 3. E Types of Database Architecture (based on physical locations of the data files and data processing) 1. Object-Oriented: Consists of inter-related objects. In this type of setup. even the processes associated with data management are distributed in various computers over network. for which links are established by the user. 2. Others can not have access to the database application. 3. Users can have access to the database application from remote computers / terminals. methods associated with the object. Knowledge Database: Consists of decision rules used to evaluate situations and help users to take decisions like an expert. 4. Hypermedia: Stores chunks information in the form of nodes. 6 Training Division. in more than one location. Geographical Information Database: Used for managing locational data for overlaying on maps and images. NIC. similar to entities consisting of attributes. New Delhi . 2. as per specific needs. usually close to the user. or portions of a database. Distributed: Database has complete copies of a database. 5. Stand alone: A stand alone database has all the related files and the procedures for processing the data at one physical location only. Emerging Data Models Relational Multidimensional Database: Used for building Data warehouse.
The divided portions of database are locally maintained and are made available to others also for retrieval and further processing etc. This is a typical example of distributed database. Usually. in which common use data is stored on the server computer. the processes at client machine. Training Division. request server to provide required data. and local requirement data is stored on client systems. NIC. so that each location has a portion of the entire database.MS-Access There are two types of distributed databases: Replicated: A replicated database has complete copies of the entire database in more than one locations. The processes at server end make the required data available at client computer for further processing. primarily to alleviate the single-point-of-failure problems of a centralized database as well as to increase user access responsiveness. In a nutshell. Partitioned: Database is subdivided. Client-Server: The present trend is to build Client / Server based databases. database technology allows an organizational data to be processed as an integrated whole. It reduces artificiality imposed by separate files for separate applications and permits users to access data more naturally. Now let us look into the procedures associated with Database Management and the tools available to do so. New Delhi 7 .
as per their specific needs. the data actually stored on a physical media) and the users( people.MS-Access E Database Management System ö Introduction Between the physical database (i. Training Division. The database application developers should be able to integrate these procedures with their application procedures. who access or update data). used by computers to achieve the orderly storage of data. NIC. which may be physically located at one computer or different networked computers Manipulation of records in tables by sorting / filtering them Searching of desired records & updating / deleting them Mathematical / logical operations on the values in the fields Facilitates design of user interface to link and automate various modules of application Processing of user queries and presentation of results in tabulated form or predesigned reports form ö 1. there is a need to follow standard procedures for data manipulation (additions/deletions/updations) & data retrieval. Components of DBMS Data Model: It defines the way. 3.e. ö 1. In computer terminology. records and files. DBMS is defined as a software tool. its processing and retrieval. 6. Major Functions of DBMS Creation / modifications / deletion of tables. 5. New Delhi 8 . A set of such procedures is called Database Management System (DBMS). 4. 2. the database is conceptually designed for setting relationship between fields.
4. NIC. Data Definition Language (DDL): It defines the structure of database. Structured Query Language( SQL): It is the most popular Relational Database language. The syntax of SQL commands is independent of Relational database brand. ö Commonly used Relational Database Management Systems Database Architecture Stand alone / Distributed Architecture based (as Client systems only) Mainly Client –Server / Centralized Architecture based. associated business functions. aliases.MS-Access 2. Data Dictionary: It stores definitions of data fields. It can be used with any other application language (3rd generation/4th generation) also. 3. and the way how. Data Dictionary helps in maintaining data consistency. each data item appears in the database. enforcement of standards. their standard names. DDL provides link between logical and physical views of the database. It actually combines both DML & DDL features of DBMS. It also enables independence of applications design from database design. Stand alone PC version also is available Client –Server / Centralized Architecture based Client –Server / Centralized Architecture based Client –Server / Centralized Architecture based Name of DBMS MS Access Oracle SQL Server UNIFY Visual Foxpro Training Division. avoid duplicacy. which allows the user to request for required information in most natural way. as per user/application requirements. Data Manipulation Language (DML): Data Manipulation Language of DBMS has the capability to write procedures for automating various DBMS functions as mentioned above. New Delhi 9 . 5. data ownership details etc.
Improved security Enhanced data integrity Reduced application development and maintenance costs Better / Automated backup and recovery procedures E Getting Started with Database Design ö Conceptual Design To begin with. 2. 2 A well defined objective of database application List of agencies who supply inputs List of agencies / roles who receive reports List of expected output reports and their layout List of inputs transactions & data entry forms layout Detailed explanation of this technique is beyond the scope of this document. Database Systems: Advantages in a Nutshell Better planning of corporate database Enforcement of standards Transparency Better control of data by providing appropriate access controls Problems like redundancy / inconsistency can be minimized Easy enhancement of database is possible without disturbing the existing working applications.MS-Access ö 1. 3. NIC. 5. 4. It mainly consists of: 1. 10 Training Division. 2. for which database and the procedures are to be designed. 8. 3. 4. 7. The output of this process is known as System Requirements Specifications (SRS). 6. This can be done by adopting systematic technique2 for structured analysis. New Delhi . 9. 5. one needs to be clear about the Information System requirements. 10.
in Library Information System.MS-Access 6. conceptual database design only will be discussed. we should have two entities about which data needs to be stored in the database. 7. 8. These are students and the books. 9. and a book can be issued to many students at different issue dates. It identifies various entities about which data needs to be stored. Entity Relationship Diagram The Entity Relationship (E-R) Diagram of a database is a model of the database from the user or business perspective. NIC. a student can get issued more than one books at a time. the relationship between the two entities will be represented as follows: M Student Gets issued M Books Training Division. 10. New Delhi 11 . For example. List of major processes Layout of User Interfaces to link various processes List of entities (something that can be identified in the user’s work environment and whose data should be stored in the database) List of properties / attributes associated with the entities Conceptual database design including the logical view of data files along with associated data elements In this section. and also the relationships between those entities. The conceptual database design is independent of type of type of DBMS. It is done in two stages as follows: 1. Since.
Here book-code is primary key. Here Student-code is primary key which is unique 2. which is unique. various tables are identified. Accession no. postal. Books table consisting of fields. In our example of Library Information System. Date of birth. There will be some common attributes. Student-name. etc…. The identified tables are linked through common data elements. After the normalization process. These common data elements are defined as Primary key / Foreign Key / Composite primary key . and some dependent attributes. NIC.MS-Access 2. Book-code. phone no. Issue table consisting of fields. Student-code and Book-code are foreign keys.. cost. Issue-date. 12 Training Division. 1. Normalization: The next step is to list out various attributes of the entities and their relationships. status Here Student-code+Book-code+ Issue-date is composite Primary key. Book-code. Class. edition. Student-code. New Delhi . which constitute record structure with grouped data elements. Student-code. and can have duplicate values. the following tables will be identified as an output of conceptual design. Book name. and maximize integrity. This process of analysis is called Normalization. These attributes ( which can be referred as data elements also) are analyzed to minimize redundancy. etc…. Author. which is unique 3. Student table consisting of fields. address.
P. New Delhi 13 . New Delhi 11. New Delhi ---- Email.Student Name Code 1 Shayam Class 1st Year 2nd Year ---- Date of birth 11/05/1985 Address 12.com 3 4 ---- ---- ----- Issue Table StudentCode 1 1 2 Book-Code 1 2 2 Issue-date 12/10/2001 14/08/2002 14/08/2002 Status Returned Books Table Book-code 1 2 3 Book Name Visual Basic MS Access-An Overview --Author I. Janpath. NIC.address shayam@yahoo. Jain R. Sector –7. Vikas Puri.MS-Access Graphical Illustration: Student Table Student. 2nd Street.K.com 2 Ashish 21/07/84 ashish@hotmail. Singh --Edition 1998 1997 --Cost 500 200 --- Training Division.
records. any changes made in the database design will not affect already working applications. That means. is called schema. Such logical view is called subschema. the actual structures of tables are created using a particular DBMS package. the DBMS supports. 14 Training Division. unless the data elements. depending upon the type of database. This physical design giving complete logical view ( the way user wants to view it) of the database.MS-Access ö Physical Design In the physical design. They can customize these views as per their specific needs. New Delhi . Various applications developers have the choice of getting different logical views (which may be even partial) of the same database. NIC. The physical design shows how the files. fields are actually stored on the physical storage media. This characteristic of DBMS makes the database design independent of applications design. being used by them are deleted from the database. DBMS provides tools for creating the subschemas .
New Delhi 15 . Reports to print information in pre-laid formats Pages to publish the reports / queries output on Web Macros to club more that one operations and automate their executions Modules to add more functionality by writing codes using Visual Basic for Applications (VBA). It is similar to Visual Basic. It has mainly the following components. interfaces etc. reports. In a Client-Server environment. Forms to manipulate data and user interfaces to link forms. it is used to maintain database at the client end. for windows based desktop database applications. which may be stand alone or distributed over network.MS-Access E Getting Started with MS-Access MS Access is a Relational DBMS. Queries to create logical view of data and also to find and retrieve desired data based on various conditions. Tables to contain data in the form of records / fields. Database in MS Access is referred as a collection of data . procedures. which is scripting language integrated with MS Access. related to a particular purpose. sub forms or processes. NIC. Training Division.
4.MS-Access q Case Study 1. List of major processes · · · Maintenance of data of Employee (Additions/Deletions/Modifications) Maintenance of record of leave details Year end processing Training Division. 2. 3. by adding leave due in the coming year. along with leave at balance List of various input forms · · · · Addition of data of new employees Updating of Employee’s information Deletion of employees. The system should also update the balance leave at the end of calendar year. Brief description of the application This application is designed for · Leave account maintenance of the employees of an organization. · Year end processing to add Earned leave and initialize Casual Leave balance. List of various reports expected to be generated · · 5. who leave the organization Data entry of leave taken by an employee from time to time 6. Name of Database application : Employees Leave Record System (ELRS) Broad objective of the application: To keep the information of employees and details of leave taken by them during the service. Employee’s details report Detailed leave report of an individual employee. NIC. New Delhi 16 .
Here Employee-code is the Primary Key. Designation. After Normalization process. End Date. Skill. NIC.Relationship Diagram ( Conceptual Design of database) Employee Takes Leave 10. Designation. Email address. Email address. New Delhi 17 . Skill. Salary. List of data items associated with above entities Employee: Name. Leave details: 9. List of entities identified ( about which the data is to be stored ) · · Employee details Leave details 8. HPL at credit. balance leave at credit. Start Date. Duration. RH at credit. Name. CL at credit. Training Division. Name of the employee. EL at credit. we will get the conceptual design in the form of the following two tables. Designation. Date of Joining. Date of Joining. employee photograph etc. Employee table consisting of fields: Employee-code.MS-Access 7. Entity . Leave type. employee photograph etc.
Start-Date. NIC. and Employee-Code is Foreign Key. Leave type. User Interfaces Design Maintain Employees data Maintain Employee Data § Add New Employee § Modify Employee Data § Delete Employee Data Enter Leave Details Form for entry of multiple leave details of an employee Enter Leave Details Year End Processing Reports / Queries Reports Page · Employee Report · Creating Employee Label · Leave Details of Individual employee 18 Training Division. 11. End Date Here Employee-code + Start-Date is a Composite Key. New Delhi . Duration.MS-Access Leave table consisting of fields: Employee-code.
and other details. This process should get triggered. Ø Ø Ø Ø On the similar lines of the case study. Publish employees list on Web along with their leave at credit. Generate MS Word document for leave details statement for every employee with a provision to send it as an attachment to email of that employee (You cal use Mail merge option). New Delhi 19 . Develop a module for periodic backup of tables. In the properties of this field. Ø Ø Ø Ø Add login screen for screen for maintaining employee data to enforce Access controls.MS-Access Few suggested enhancements to the above mentioned case study. to which employee belongs. This process should get triggered. add a field for department. Develop a module for automatic backup of tables. NIC. on mouse click on the main menu. Add a filed in Leave table to set hyperlink to leave sanction order (MS Word file). pickup the values for department field from the department table through lookup Wizard. automatically on 1st day of every month. you can also develop a database application relevant to your work area. In employee table. which can be done by participants as assignment. Calculate gross pay of employees and generate pay slips by automatically calculating DA from the basic salary. Training Division. Create a new table containing department code.
Figure 1 Ø Select Blank Access database option. New Delhi . Select this for blank database option. Click Start>>Programs>>MS Access. for Cabin 42. The dialog box shown in Figure 2 will appear. NIC. 20 Training Division. user name and password will be user42).MS-Access q Starting MS Access Ø Ø Ø Switch on the system. enter user name and password as User (Cabin No) (For example. In case login dialog box appears. Dialog box shown in Figure 1 will appear.
To open table for data entry To make modification in design of table Figure 3 To create new table Training Division. Click Create. New Delhi 21 . NIC. Employee database window will open as shown in Figure 3. Type Employee under File name.MS-Access Figure 2 Ø Ø Ø Select the folder name in Save in option.
their data types and properties have to be entered. different objects of the database like Tables. Note: Another way to get Design view for new table. can be created by selecting appropriate tabs. Ø Click New>>Design View>>OK. Forms. only data has to be entered and it will take fields names as field1. Queries. New Delhi . Note: We are going to refer to this database window in later part of the workbook also. 22 Training Division. Ø New Table dialog box will appear as shown in Figure 4. E Creating New Table Ø Double click Create table in Design View. E Ways of Creating a Table ö Create table in design view In this option. ö Create Table by using Wizard In this option. wizard dialog box will open with the steps provided to create a table. field2 and so on and data type it will take automatically based upon data entered (one can rename the fields names. table has to be created from scratch. in which its fields names. Reports etc. ö Create table by entering data In this option.MS-Access After the database has been created. if required). NIC.
NIC. enter names of fields in Field Name column. Figure 5 Training Division. New Delhi 23 . type of data to be entered in fields in Data Type column and enter description of fields in Description column if required.MS-Access Figure 4 Ø As shown in Figure 5.
Table will be saved with the name Employee. NIC. Figure 7 Ø Ø Select No. New Delhi .MS-Access E Saving the Table Ø Click File>>Save.Datasheet View of the table will open as shown in Figure 8. The dialog box as shown in Figure 7 will appear. Close the table Employee. Click Open. Training Division. The dialog box as shown in Figure 6 will appear. Figure 6 Ø Type the Table name as Employee and click OK. E Adding Records to a Table Ø Ø 24 Select table Employee from database window.
Select Edit>>Select Record. NIC. The following data may be entered as shown in Figure 9. New Delhi 25 . E Deleting Records Ø Ø Click on the record to be deleted.MS-Access Figure 8 Ø Start entering the data from the cursor placed at the first blank record . The record gets selected as shown in Figure 10. Figure 10 Training Division. Figure 9 Ø Save and Close the table window.
New Delhi . Figure 11 26 Training Division. by clicking the Field Heading OR put the cursor anywhere in the column where the data has to be searched. Take the cursor to a new position in the table where the record is to be copied. NIC. the record will be deleted. Select Edit>>Paste. But don’t try this option otherwise you will lose whole data of that table. Click Edit>>Find. E Editing Data in Tables ö Ø Ø Ø Ø Cutting & Pasting Or Copying & Pasting Data Select the record to be cut or copied. Note : To delete all record.MS-Access Ø Click Edit>>Delete Record from the menu bar. Click here to select the field. Select Edit >> Cut (for cutting data) or Edit>>Copy (for copying data). click Edit>>Select All and press Delete button. The Find and Replace dialog box appears as shown in Figure 11. ö Ø Ø Locating Data Select the field where the data has to be searched.
Select Cancel to stop the search and close the dialog box. Click on Find Next button. Type SSA. Click on the Replace With field. ö Ø Replacing the existing data Click on the field name where the data is to be replaced. say ANIL. select any of the three category provided. in the Find What: option. It will find the first occurrence of the data. NIC. Close the Find and Replace dialog box by clicking the Close button. Figure 12 Ø Ø Ø Ø Ø Ø Type SA in Find What field.MS-Access Ø Ø Ø Ø Enter a string to search for. New Delhi 27 . Click on Find Next to find and then click Replace to replace the next occurrence of the data (If required. click Replace All to replace all such occurrences). Click on Replace to replace the data in that field. In Match option. The Replace dialog box as shown in Figure 12 will appear. Training Division. For example. Choose Find Next to search for more records. click on Designation field Ø Select Edit>>Replace.
Ø Click Records>>Sort>> Sort Ascending from the Record menu option. Ø Click on the Field on which the records are to be sorted. if changes are to be saved in the table. i. or earliest to latest date). Select Design. New Delhi . After the modification. The table will open in Design View. the fields can be deleted. Or. you can sort in descending order (Z to A.e. numbers. NIC. or latest to earliest date). Figure 13 Ø Ø Close the table window Click Yes. 28 Training Division.. 9 to zero.MS-Access E Sorting Data Data stored in a table can be sorted on text. added or changed according to the requirements. zero to 9. The option provides you to rearrange the records Ascending/Descending on Name field as shown in Figure 13. changes can be saved and the database window reappears. E Modifying Table Design Ø Ø Select the table to be modified from the database window. The design of the fields in table can now be modified. or date fields in ascending order (A to Z.
Access will do the following things: 1. NIC. New Delhi 29 . Make sure no two records in the table have the same value in the field (or group of fields) that defines the primary key.MS-Access E Primary Key A Primary Key is a field (or group of fields) that uniquely identifies each record. 2. Speed up processing. 3. the error message will be displayed while defining the emp_code field as a primary key. will have key icon in the row selector as shown in Figure 14. ö Setting a Primary Key Ø Open the table in Design view. To remove the error. first remove the duplicate data and then define field as a primary key. key icon row selector Figure 14 Note: If the data in a table contains duplicate data for the emp_code field. Training Division. Keep records sorted (ordered) by the entries in the primary key. Ø Click Edit>>Primary Key. Note: No field that is part of a primary key can be left blank during data entry. Ø Select the field for which primary key property has to be set. The field which is set as the primary key. When primary key is created.
MS-Access ö Ø Ø Removing Primary Key Setting Select the field for which primary key setting has to be removed. Close the table design window and enter the data for this table. Click Edit>>Primary Key. NIC. 30 Training Division. New Delhi . It will remove primary key setting. It may be noted that the values of Emp-code should be the same as those already mentioned in the Employee table. E Creating Second Table Let us now create another table Leave with the following fields: Emp_code Type_Leave Start_Date Duration End_Date Ø Ø Number Text Date Number Date Save this table as LEAVE table.
To bring the relevant information together in a Form/Report/Query. relationship between the two tables Employee and Leave is required. To create a report. Figure 15 E How it works ? In the above example. which contains the information about the leaves taken by all the employees. which contains employees details. For example. NIC. which will give the details of the leaves taken by all the employees. A relationship is created by matching data in one of the fields of the table— usually a field with the same name in both tables. To link the tables together Relationships are used. New Delhi 31 . In most cases. usually data is stored in more than one table. the fields in both tables must be linked so that they show relevant information about the employees.MS-Access q Relationships In RDBMS systems. Sample report having data from both the tables is shown in Figure 15. these matching fields Training Division. there are two tables– Employee table. these tables need to be linked together. depending on the type of information. and other Leave table. This linking is done by setting relationships between tables.
4 Foreign key is one or more table fields (columns) that refer to the primary key field or fields in another table. A primary key cannot allow Null values and is used to relate the table to foreign keys in other tables. NIC. 32 Training Division.MS-Access are the primary key3 from one table and a foreign key4 in the other table. The data in the foreign key and primary key fields must match. For example. Primary Key Employee Table Foreign Key Leave Table Figure 16 Entity-Relationship diagram Employee Table’s Emp_code Takes Leave Leave Table’s Emp_code 3 Primary key consists of one or more fields (columns) whose value or values uniquely identify each record in a table. though the field names do not have to be the same. employees can be associated with the leaves they have taken by creating a relationship between the Employee table and the Leave table using the Emp_code (Employee Code) field as shown in Figure 16. A foreign key indicates how the tables are related. New Delhi .
and each record in the second table can have only one matching record in the first table. a record in the first table can have many matching records in the second table. each record in the first table can have only one matching record in the second table. A many-to-many relationship is actually defining two one-to-many relationships with a third table. one-to-many relationships to the Employee table. 33 Training Division. but a record in the second table has only one matching record in the first table. to isolate part of a table for security reasons. New Delhi . NIC. A many-to-many relationship In a many-to-many relationship. or to store information that applies only to a subset of the main table. because most of the information related in this way would be in one table. first and second.MS-Access Types of Relationship 1. This type of relationship is only possible by defining a third table (called a junction table) whose primary key consists of two fields — the foreign keys from both the tables. a record in the first table can have many matching records in the second table. A one-to-one relationship In a one-to-one relationship. For example. 2. This type of relationship is not common. A one-to-many relationship : It is the most common type of relationship. the Leave table and the Training table have a many-to-many relationship that’s defined by creating two. Blank screen will appear. and a record in the second table can have many matching records in the first table. Click Tools>>Relationships. 3. E Creating New Relationships Ø Ø Close any tables you have opened since relationships can’t be created or modified between open tables. In a one-to-many relationship. You might use a one-to-one relationship to divide a table with many fields.
NIC. Select Leave table. Figure 17 Ø Ø Select Employee table. Tables selected will appear as shown in Figure 18. Following Show Table dialog box will appear as shown in Figure 17.MS-Access Ø Click Relationships>>Show Table. Training Division. New Delhi 34 . Click Add. Edit Relationships dialog box will appear as shown in Figure 19. Figure 18 Ø Drag the Emp_code of Employee table over Emp_code of Leave table to relate them. Similarly you can add more tables depending upon the requirement. Click Add. Ø Click Close.
The system will prompt for the Saving of Relationship. Figure 20 The above two steps can be repeated for each pair of tables you want to relate. A line joining the two tables will appear as shown in Figure 20.MS-Access Figure 19 Ø Click Create. Note: If you drag a field that isn’t a primary key and doesn’t have a unique index to another field that isn’t a primary key and doesn’t have a unique index. Ø Close the Relationships window. Ø Click Yes. Training Division. NIC. New Delhi 35 . an indeterminate relationship is created.
36 Training Division. Double click on the middle of the relationship line. button. Figure 21 ö Ø Defining the join type for a relationship between two tables Click the Join Type.MS-Access E Editing the Existing Relationship Ø Ø Click Tools>>Relationships. NIC. Edit Relationship dialog box will appear as shown in Figure 21. and then click the desired join type from the Join Properties dialog box as shown in Figure 22. New Delhi .
ö Ø Ø Ø Deleting Relationship Click Tools>>Relationships. New Delhi 37 . Press Delete key. Training Division. NIC. Press Delete key. ö Ø Ø Ø Removing Table from the Relationship Window Click Tools>>Relationships. Click on the Relationship line to be deleted. Click on the table to be deleted.MS-Access Figure 22 Ø Click OK.
one should just delete the corresponding leave details from the Leave table. 2. 3. If referential integrity is enforced and you break one of the rules with related tables. For example. Setting Referential Integrity Open the relationship in edit mode as already discussed in Editing the Existing Relationship section. you can’t delete an employee record from the Employees table if there are leave details for that employee in the Leave Table. Ø Select the Enforce Referential Integrity check box. NIC.MS-Access Referential Integrity Referential integrity is a system of rules that Microsoft Access uses to ensure that relationships between records in related tables are valid. You can’t change a primary key value in the primary table. Microsoft Access displays a message and doesn’t allow the change. Changing a primary key value in the primary table automatically updates the matching value in all related records. If at all it is required to delete a record in Employee table. Both tables belong to the same Microsoft Access database. When referential integrity is enforced. The matching field from the primary table is a primary key or has a unique index. 5 Ø 38 Training Division. and that you don’t accidentally delete or change related data. The related fields have the same data type. 3. You can’t enter a value in the foreign key field of the related table that doesn’t exist in the primary key of the primary table. Basic requirement for setting up referential integrity: 1. New Delhi . 2. Restrictions can be overridden against deleting or changing related records and preserving referential integrity by setting the Cascade Update Related Fields5 and Cascade Delete Related Records6 check boxes. you must observe the following rules: 1. if that record has related records. 6 Deleting a record in the primary table deletes any related records in the related table. You can’t delete a record from a primary table if matching records exist in a related table.
Click on OK.MS-Access q Query A query is logical view of selected data elements from tables as per the specific needs of the user (which is called subschema). Query option is used for the purpose of display. E Simple Query Ø Ø Select Queries tab from the database window. Figure 23 Ø Ø Select Design View. updating or analysis of data. The dialog box for new query will appear as shown in Figure 23. The Show Table dialog box lets you select the tables/queries/both for creating a query. Ø Ø Select the table Employee. Click on Add. Training Division. Click on New button as shown in Figure 3 of table design. NIC. New Delhi 39 . The field list appears next to the Show Table dialog box as shown in Figure 24.
Designation. NIC. They may appear in the lower part of the screen as shown in Figure 25. 40 Training Division. click on Close button. Double Click on fields Emp_code. eName.MS-Access Figure 24 Ø Ø In Show Table dialog box. Note: From the database window also the query can be run. Salary in the field list. choose the query as Employee_query and click on Open button. Figure 25 Ø Ø Ø Save the query as Employee_query. Select Query>>Run from the menu bar to see the output. Click on Queries tab. Close the Select Query window. New Delhi .
42 Expression to calculate DA Figure 26 Note: For creating the expression. with the field name DA. Close the Query window. The calculated value for DA. will be displayed in the output of query. Training Division. NIC. New Delhi 41 . and then click Build. Expression Builder can be used. Right-click in the Field cell where you have to add the calculated field.MS-Access E Performing Calculation in the Query A new field can be created in a query that displays the results of a calculation defined in field cell with an expression. Ø Ø Select Query>>Run to see the output. Repeat all the steps as done in previous query. Type an expression in an empty cell in the Field row as shown in Figure 26. Ø Ø Ø Open the query in Design view. In this figure the expression written is DA:[Salary]*0.
the expressions are in different cells in the same row. The output contains only those records having Designation equal to SA. instead of viewing all the employee information of your organisation. specify the criteria that limits the results to records whose Designation field has the value “SA”. The expression in the preceding example would be “SA” as shown in Figure 27. Note : Additional criteria can be entered for the same field or different fields using either the And or the Or operator. For And operator.MS-Access E Using Criteria or Advanced Filters to retrieve certain Records Criteria are restrictions or an advanced filter placed on a query to identify the specific records to work with. Figure 27 Ø Select Query>>Run. For Or operator. 42 Training Division. For example. New Delhi . NIC. enter an expression in the criteria cell for the field. selected employees can be viewed having Designation “SA”. To do this. the expressions are in different rows of the design grid. Ø In a design grid of query.
designation. for example. NIC. Training Division. Figure 28 Ø The prompt “Type Employee Code” will be displayed when you run the query as shown in Figure 29. Figure 29 Enter the value for employee code and click OK.MS-Access E Parameter Queries A parameter query is a query that while running displays its own dialog box prompting you for information. You can design the query to prompt you for more than one piece of information. type a prompt enclosed in square brackets as shown in Figure 28. such as criteria for retrieving records or a value you want to insert in a field. New Delhi 43 . It will display the output having emp_code. name. Microsoft Access can then retrieve all records that fall between those two dates. you can design it to prompt you for two dates. Ø Ø In query Design view. In the Criteria cell for the field you want to use as a parameter. drag the fields from the field list to the query design grid. salary and DA for the corresponding employee code.
update. from the Menu bar. criteria has to be typed as shown in the Figure 30. NIC. Ø From appears in the Delete cell under this field. With delete queries. New Delhi . Where appears in the Delete cell under this field. make-table. Ø Add tables Employee and click the Close button. Ø Select Query>>New>>Design View from Database dialog box. to the query design grid. always entire records will be deleted. Ø Add field and table to the design grid for which criteria for deleting records has to be specified. In the Criteria cell for the fields. Ø Drag the asterisk(*) from the field list for the table. in a one-to-one relationship or a one-to-many relationship. if relation has been set between the tables.MS-Access E Action Queries An action query is a query that makes changes to many records in just one operation. 44 Training Division. from which records are to be deleted. The action queries are of four types: delete. Single delete query is used to delete records from a single table or from multiple tables. and append queries ö Delete Query Delete Query deletes a group of records from one or more tables. not just selected fields within records. Ø Select Query>>Delete Query.
For example. the Delete Query will delete the records from both the tables related. tables Employee and Leave are having oneto-many relationship (select the Cascade delete related records option while setting the relationship. Ø Ø To see a list of the records going to be deleted. click View >>Design View. Training Division.) In this case. if the Salary is less than 9500. Click Query>>Run to delete the records permanently from the tables. NIC.MS-Access Figure 30 Note: If Delete Query is used for One-to-many relations. To return to query Design view. click View >>Datasheet view. records will be deleted from all the related tables. New Delhi 45 .
NIC. This list won’t show the new values.MS-Access ö q Update Query Change records as a group using an update query Create an update query. Drag from the field list to the query design grid the fields you want to update or you want to specify criteria for. Click Query>>Run to make the table updated. In the Update To cell for the fields you want to update. click View >>Datasheet View. New Delhi . In the Criteria cell. To return to query Design view. Ø Ø Ø Ø Ø Figure 31 Ø Ø To see a list of the records that will be updated. click the Query>>Update Query. as shown in Figure 31. specify the criteria if necessary. selecting the tables or queries that include the records you want to update and the fields you want to use for setting criteria. In query Design view. 46 Training Division. click View >> Design View. type the expression or value you want to use to change the fields.
where tablename and fieldname are the names of the table and field that contain the data you’re copying. if you are copying data from the Name field of the Employee table.MS-Access q Update a table based on values in another table Create an update query that contains the table you want to update and the table whose values you want to copy. For example. (To see the updated table. you may see the Leave table in Datasheet view). type an expression with the following syntax: [tablename]. Ø In the Update To cell for the fields you want to update. It will copy the data from Name field of Employee table to the Name field of the Leave table. New Delhi 47 . you would type [Employee].[Name] in the Update To cell as shown in Figure 32. For example. Ø If the tables aren’t already joined. if you want to copy data from the Name field of the Employee table to a field in Leave table. join the two tables on the primary key. Training Division. which in this case is Emp_code. NIC. join them on the fields that have related information.[fieldname]. Figure 32 Ø Click Query>>Run.
MS-Access ö Ø Ø Ø Ø Make-table Query Create a query. For example. In the Criteria cell for the fields that you’ve dragged to the grid. NIC. enter the name of the table you want to create or replace. In the Table Name box. type that name in the Table Name box. New Delhi . type the criteria as shown in Figure 33. selecting the tables or queries that contain the records you want to put in the new table. Ø Ø Ø Figure 33 48 Training Division. Or click Another Database if you want to create table in a new database and type the name of the database you want to put the new table in. to create new table “employee_new”. click Query >> Make-Table query. The Make Table dialog box appears. Click Current Database to put the new table in the currently open database. Type the path if necessary. Drag from the field list to the query design grid the fields you want in the new table. Click OK. In query Design view.
The Append dialog box appears as shown in Figure 34. click the View>> datasheet view. Return to query Design view by clicking View>>Design View. To create a new table.MS-Access Ø Ø For the preview the new table before you actually create it. Click Current Database if the table is in the currently open database. Type the path if necessary. Figure 34 Ø Ø Ø In the Table Name box. New Delhi 49 . Training Division. enter the name of the table you want to append records to. click Query>>Run. Ø Click Query>>Append Query. It will copy all the fields shown in Figure 33 and its data to the newly created table employee_new. ö Append Query This query is used to append records from one table to another table using an append query. Or click Another Database and type the name of the database where the table is stored. Ø Create a query that contains the table whose records you want to append to another table (can be done using Simple Query Wizard option). NIC. Click OK. Ø Open the query created in the above step in design mode.
If the fields you’ve selected have the same name in both tables. in the Append To row. For further details. 50 Training Division. However. New Delhi . enter the names of the fields in the table you’re appending to. you’ll need to add all the fields instead. you can just drag the asterisk (*) to the query design grid. If the fields in the two tables don’t have the same name. In the Criteria cell for the fields that you have dragged to the grid. if you’re working in a database replica.MS-Access Ø In Append To option. Click Query>>Run to execute the query. Figure 35 · · · If all the fields in both tables have the same names. NIC. Ø Note : So far. type the criteria on which additions will be made. the practice for basics of Queries has been done. Microsoft Access automatically fills the matching name in the Append To row. select the Field name of the table where the data has to be appended and in Criteria cell for appending the field value as shown in Figure 35. else go to the Section on Forms on Page 59. you may continue through the following pages.
Ø Ø Ø Click New>>Design View>>OK. NIC. Add table Leave to be worked upon as shown in Figure 36. More than one field can be designated. average. The example shown below answers the question “Who took how many leaves of what type ?”. New Delhi . which field’s values become row headings. count. Steps for creating Cross-tab query are as follows: Ø Choose Row Heading in the Crosstab cell for the field you want to use for row heading. or otherwise calculate). 51 Training Division.MS-Access E More about Queries ö Cross-tab Query Cross-tab queries let you cross-tabulate data in a row-by-column fashion. Note : To quickly create Cross-tab query of data in a single table. and the summary values and how you want to summarize the value (for example. sum. Expressions can also be used to group the value together. but at least one field must be Group By in its Total Cell as shown in Figure 37. specify which field’s values become column headings. Click Query>>Cross-tab query. Figure 36 In the design grid of query. Crosstab query Wizard can be used.
you want to group by. For the setting in design grid of query. These settings will display the field’s value as Row headings These settings will Display the field’s value as a Column heading. without displaying them in result. NIC. Choose the summary value in the Crosstab cell for the field you want to summarise.MS-Access Ø Ø Ø Ø Choose Column Heading in the Crosstab cell for the field you want to use for column heading. In the Total Cell. Only one field is allowed and it must contain Group By in its Total Cell as shown in Figure 37. New Delhi . Click View>>Datasheet View to view the result. result is shown in Figure 37. These settings display the total of leaves. Figure 37 52 Training Division. Expressions can also be used to group the value together. Don’t choose Group By for this field. Other fields can also be chosen in Crosstab cell. choose the summary (usually it is Sum or Average).
NIC Cell in ministries have to give the attendance report of its staff each month to NIC HQ. Examples of SQLspecific queries are: q Union Query This type of query combines fields (columns) from one or more tables or queries into one field or column in the query’s results.MS-Access ö SQL specific Query An SQL query is a query that is created using an SQL statement. Click on Query>>SQL Specific>>Union. Add tables minis1 and minis2. New Delhi 53 . Figure 38 Ø Ø Ø For Union Query. The two tables Minis1 and Minis2 are shown in Figure 38. NIC. These two lists can be combined through union query. These lists from all ministries can be combined into one result set using a union query. select Queries >>New then click Design View>>OK. For example. and then create a make-table query based on the union query to make a new table. Training Division. For example NIC HQ is getting the attendance list from two ministries Minis1 and Minis2.
such as Microsoft SQL Server.[ATTENDENCE] FROM MINIS1 WHERE MONTH=”JANUARY” UNION SELECT [EMPCODE].MS-Access A Union Query window is opened. pass-through query can be used to retrieve records or change data. For example. q Data-definition Query This type of query creates or alters database objects. New Delhi . [ATTENDENCE] FROM MINIS2 WHERE MONTH=”JANUARY”. Figure 39 q Pass-through Query This type of query sends commands directly to ODBC databases. Type the SQL statement given below: SELECT [EMPCODE]. NIC. The output will be as shown in Figure 39. Ø Click Query>>Run. using commands that are accepted by the server. such as Microsoft Access or Microsoft SQL Server tables. 54 Training Division.
Figure 40 Ø Click View>>Datasheet View. To Zoom the field cell press Shift+F2.EMP_CODE.NAME)=”Sushila”)). Note : If subquery is defined in a Field cell. Ø Type “Sushila” in criteria row and in name column as shown in Figure 40. For example: Leave taken : (select [duration] from [ leave] where [employee]. NIC. Employee.NAME FROM Employee WHERE (((Employee. or in the Criteria row to define criteria for a field. New Delhi 55 . type a SELECT statement enclosed in parentheses in a Field cell.[emp_code]) Training Division. These statements can be entered in the Field row of the query design grid to define a new field. The output will be displayed having those records where NAME=”Sushila”.[emp_code]=[leave]. Ø Add table Employee for this query and write the following SQL statement: SELECT Employee.MS-Access q Subquery This type of query consists of a SQL SELECT statement inside another select query or action query.
MS-Access Figure 41 In the example shown in Figure 41. The output will be as shown in Figure 42. first create Form having combo box and a button as shown in Figure 43. Ø Click Query>>Run. To do this. In this Query. 56 Training Division. we want to display all the employees details having the same designation. two tables Employee and Leave are used with the relationship set on the field emp_code. New Delhi . Emp_code and Name from Employee table and duration from Leave table is selected where the emp_code of both the tables are equal. Figure 42 E Accessing Query through Form To access query through form. NIC. first create a form having the fields on which the criteria is to be set in the query and then create a button to run the query. For example.
Figure 44 Training Division. Create a query. Here forms mean that a form is called. NIC.MS-Access Figure 43 To do this. Form1 is the form name. Query new having all the required fields to display and in Criteria cell of Designation field give criteria [forms]![form1]![combo1] Create Button and in Command button wizard. Combo1 is the field from where value is taken for criteria. in a design mode of form Ø Ø Ø Create combo box having all the Designation from the designation field of the table. New Delhi 57 . select category Miscellaneous and action Run Query. The design view of query is shown in Figure 44.
NIC.MS-Access To get the output Ø Run the form and enter the value for designation and click button Run Query. Output will be displayed as shown in Figure 45. Figure 45 58 Training Division. New Delhi .
NIC. Design and New. Switchboard. As in the case of tables and queries. click New>>Form wizard>>OK or Double Click on Create form by using wizard. To create a new form. The dialog box shown in Figure 46 appears. Ø User interface forms to set links to various actions to be performed on the application. E Creating a Form using Wizard Ø Ø Ø Select Forms tab from the database window. which can be customized as per user requirements and is used for the following purposes: Ø Forms for data-entry in one or more than one table. for example. New Delhi 59 .MS-Access q Forms A form is a graphical user interface. and then carry out an action based on that input. for forms also there are three option buttonsOpen. Ø To create custom dialog box to accept user input. Figure 46 Training Division.
To go in design view of form. NIC.MS-Access Ø Ø Ø Ø Ø Select the table Employee from the Table/Query7 listbox. New Delhi . Select the layout and style of the form in the next two steps. 60 Training Division. Note : Modification in the form can be done in the Design view of the form. The form will be opened in the Form View mode as shown in Figure 47. Type the title of the form as Employee and click Finish. Figure 47 Ø Close the form. Select the fields to be displayed on the form. click View>>Design View. 7 A form can take the data from table or query for viewing and editing purpose. Click Next.
This will give the field list as shown in Figure 49. click the Forms tab. NIC. Click New. Figure 48 Ø Select View>>Field List. don’t select any Table or Query from this list. or if you want to create a custom dialog box). Close the form. Training Division. New Delhi 61 . Form will appear as shown in Figure 48. click Design View. empform. if you want to create a form to use as a switchboard to open other forms or reports. Ø Click OK. In the New Form dialog box. Ø Ø Save the form and give it a name. Form will appear as shown in Figure 49. The required fields can be dragged on to the form. say.MS-Access E Creating a Form in Design View Ø Ø Ø Ø In the Database window. Note : If the form won’t contain data (for example. Select the name of the table or query that includes the data you want to base your form on.
as shown in Figure 50. double click the empform you will be able to see different records from the form.MS-Access Field List Figure 49 Ø From the Database window. NIC. New Delhi . Figure 50 62 Training Division.
E Different Controls
In a form, we can also introduce many controls. Various controls (like label, textbox, combobox, command button, tab etc.) available on the tool bar as shown in Figure 51, can be put on the form.
Label on a form or report is used to display descriptive text such as titles, captions, or brief instructions. Labels do not display values from fields or expressions; they’re always unbound and they don’t change as you move from record to record. Ø Open a form in Design view Ø Click the Label tool in the toolbox. Ø On the form, click where you want to place the label, and drag the mouse. Ø In the label drawn, type the text for the label. ö
Text boxes are drawn on a form or report to display data from a table, query, or SQL statement. This type of text box is called a bound text box because it’s bound to data in a field. Text boxes can also be unbound8 . For example, you can create an unbound text box (i.e. text box isn’t bound to the data in field) to display the results of a calculation, or to accept input from a user.
Data in an unbound text box isn’t stored in field of table.
Training Division, NIC, New Delhi
Create a bound Text box Ø Open a form in Design view. Ø Click View>>Field List. Drag the field(s) from the field list and position them on the form. Create an unbound Text box Ø Click the Text Box Tool in the toolbox. Ø Click anywhere on the form to create a default-sized text box, or drag to create a text box that’s the size you want. Create a Text box for computed Fields (for numeric and text entries) Ø Open a form in Design view and select a table from the New form dialog box Ø Click the textbox tool in the toolbox. Click on the form where the control has to be placed and do the following:Note: A text box is the most common type of control used to display a calculated value, but you can use any control that has a Control Source property. Ø Type the expression in the Control Source property of the textbox. For example, for the calculation of DA, type expression = [salary] * 0.43 in the Text box.
Note: To use the Expression Builder to create the expression, click View>>Properties to open the control’s property sheet, and then type the expression in the Control Source property box or click the Build button to open the Expression Builder.
Ø Ø Ø Ø
Create a command button
with a wizard
Open a form in Design view. Click the Control Wizards tool in the toolbox if it’s not already pressed in. In the toolbox, click the Command Button tool. On the form, click where you want to place the command button. The wizard dialog box will be opened as shown in Figure 52.
Training Division, NIC, New Delhi
Follow the directions in the wizard dialog boxes. In the last dialog box, click Finish to display the command button in Design view. You may introduce many buttons on the form like this. The view of buttons will appear as shown in Figure 53.
Training Division, NIC, New Delhi
Create a List Box or combo box
List box or combo box is quicker and easier way to select a value from a list than to remember a value to type. The list in a list box consists of rows of data. Rows can have one or more columns, which can appear with or without headings. If data type of field is Lookup field in table Ø Create a Lookup field in table Design view by selecting Lookup Wizard as Data Type and follow the directions in the wizard dialog boxes and create a new form based on a that table. Ø In form Design view, click view>>Field List and then drag the Lookup field from the field list to the form. Microsoft Access automatically creates the lookup list box or combo box. OR If data type of field is not a Lookup field in table . Ø Open the form in Design view. Ø In the toolbox, click the ListBox or ComboxBox and then click on the form where these controls have to be placed and follow the directions in the Wizard dialog boxes. Ø Switch to Form view to test the list box or combo box. It will appear as shown in Figure 54.
Training Division, NIC, New Delhi
select Navigation Button option to NO. NIC. It will appear as shown in Figure 56. Click here to open form property dialog box. Figure 56 Ø In the form properties. are as follows: Ø Open the form properties by right clicking the mouse button by placing the cursor at left most corner of the form in design view as indicated by arrow. The view of the form will appear without navigation bar at the bottom Training Division. we generally have a navigation bar which is used to display the record no. Figure 55 The steps to remove the navigation bar from the view of the form. New Delhi 67 . A navigation bar is shown in Figure 55.MS-Access ö To remove navigation bar from the view of form At the button of each form.
The primary form is called the main form. New Delhi . Figure 57 In this figure. or a parent/child form. A form/subform combination is often referred to as a hierarchical form. and the form within the form is called the subform. The view of the form will appear as shown in Figure 57. a subform is created using table personalinfo having one to many relationships with the table Training. Make sure the Control Wizards tool in the toolbox is pressed in. Subforms are especially effective when data has to be shown from tables or queries with a one-to-many relationship.MS-Access ö Creating Subforms A subform is a form within a form. NIC. Follow the directions in the wizard dialog boxes. 68 Training Division. a master/detail form. Click the Subform tool in the toolbox and click on the form where the subform is to be placed. Ø Ø Ø Ø Open the form in Design view in which subform has to be added.
New Delhi . or Page Order. ö Ø Ø Adding pictures. Form will appear as shown in Figure 58. Select Insert>>Object to add Excel Sheet. If you don’t specify a name in the Caption property. NIC. delete. click the border of the tab control with the right mouse button and click Insert Page. The first page is on top. to the form. presentation. and then specify a new name in the Caption property. Microsoft Access adds a tab control with two pages. Chart. In the toolbox.MS-Access E Further Enhancements in Form Design ö Ø Ø Form with multiple pages using tabs Open a form in Design view. select Insert>>Picture or Insert>>Chart. Delete Page. or change the order of tabs. To add. etc. Microsoft Access uses the setting in the Name property. double-click the page (Page1 or Page2) to open its property sheet. click the Tab Control tool and then click on the form where the control has to be placed. graphs and sound to a Form To add a picture or chart to the form. 69 Training Division. bitmaps. Ø Figure 58 Note: To change the name of a Page tab. Choose the picture from the available ones or make one of your own. Click Field List on the toolbar to display the field list and drag one or more fields to the tab page by selecting option Page1 or Page2.
The output of the form will appear as shown in Figure 59.MS-Access Ø Ø Ø Ø Create a new object by selecting Create New or use the already existing object by selecting Create from File option. Select the value in form view or database view (as shown in figure. ö Ø Ø To view selected records through a form In a view of form or subform or datasheet. select Sound. Check the Display As Icon option In the Object type dialog box. Figure 59 70 Training Division. the Designation value SSA is selected for filter) and then click Filter By Selection on the toolbar. Select OK. select the entire contents of that field on which filter’s results is based. New Delhi . NIC.
MS-Access ö Ø Ø Ø Ø Adding page Numbers and Date Open the form in Design view. and then click a date format. and alignment for the page number. select Hyperlink. Figure 60 Training Division. NIC. Click Insert >> Page Numbers or Insert >> Date And Time. Microsoft Excel. ö Ø Ø Ø Ø Create a field to store hyperlinks that will change for each record Open an existing table in Design view or create a new table. ö To create a hyperlink in the form Hyperlinks can be used in forms and datasheets to jump to objects in the same or another Microsoft Access database. Type a field name for the field used to store the hyperlinks. to documents created with Microsoft Word. New Delhi 71 . and Microsoft PowerPoint. and to documents on the global Internet or on a local intranet. The table in design view is shown in Figure 60. select the format. select the Include Date check box. position. Save and close the design of the table. The hyperlinks can be created on a form in different ways. In the Page Numbers dialog box. In the Data Type column for that field. To include a date.
Figure 61 shows the details of Link to: E-mail Address Figure 61 Note : The hyperlink can be followed from the datasheet view of the form. In E_mail field. 72 Training Division. NIC.MS-Access Ø Ø Open the table in Datasheet View to enter data. In the insert hyperlink dialog box. select the appropriate tab for Link to and fill all the details. Click Insert>> Hyperlink. New Delhi .
Click the Image Control tool in the toolbox. and then click on the form where you want to create the button. 73 Training Division. From the Insert picture dialog box browse and select the graphic file you want to insert. Select the properties of the button. Click the Button tool in the toolbox. New Delhi . specify a path to a file on your hard drive. specify a UNC path or a URL in the Link To File Or URL box. ö Ø Ø Ø Ø Ø Create a command button that you can click to follow a hyperlink Open a form in Design view.MS-Access ö Ø Ø Ø Create a label that you can click to follow a hyperlink Open a form in Design view. NIC. or a URL. or on a local area network. The hyperlink apprears on the form which can be placed anywhere on it ö Ø Ø Ø Ø Ø Add a picture that you can click to follow a hyperlink Open a form in Design view. or click the Browse button to navigate to a file on your hard drive. specify a path to a file on your hard drive. Click the Control Wizards tool in the toolbox to turn off the Control Wizard. In the Hyperlink Address property. a UNC path. In the Hyperlink Address property. a UNC path. and then click on the form where you want to create the picture. select the properties of the picutre by right-clicking on it. In the Insert Hyperlink dialog box. Click Insert >>Hyperlink on the toolbar. or a URL. After inserting the image.
Charts and ActiveX Controls
Add a new chart to a form Ø Ø Ø Ø Open the form in Design view. Click on Insert >>Chart. On the form, click where you want to place the chart. Follow the directions in the Chart Wizard, which creates the chart based on available tables or queries and the fields you select.
Add an ActiveX control (OLE custom control) to a form Ø Ø Ø Ø Ø Open a form in Design view. Click the More Controls tool in the toolbox. Click the control you want in the list. On the form, click where you want to place the control. Right-click the control, and then click Properties to open the ActiveX control property sheet. Set the necessary properties.
The effectiveness of a form can be increased by adding one or more sections. Most forms have just a detail section, but a form can also include form header, page header, page footer, and form footer sections. To insert Form Header/Footer And Page Header/Footer Ø Ø Click View>> Form Header/Footer or Click View>> Page Header/Footer Give the appropriate title to the form in the Form Header section as shown in Figure 62.
Training Division, NIC, New Delhi
Training Division, NIC, New Delhi
A report is an effective way to present data in a required printed format because of control over the size and appearance of objects on a report. Most of the information in a report comes from an underlying table, query, or SQL statement, which is the source of the report’s data. Other information in the report is stored in the report’s design.
E Creating a Report using Wizard
Ø Select Reports tab from the database window. Ø Select New. The New Report dialog box appears as shown in Figure 63.
Training Division, NIC, New Delhi
NIC. Figure 64 Ø Ø Select the fields by pressing . Report Wizard automatically creates a report based on the selected fields of the table/query selected. Click on Next. Salary from the list of available fields as shown in Figure 64. Select the fields NAME. New Delhi 77 .MS-Access Access gives various options for report creation. Click OK. DESIGNATION. Next screen will appears as shown in Figure 65. Training Division. The report picks up the name of the table to be taken as the title of the report. Ø Ø Ø Ø Click on Report Wizard. Select the table Employee on which the report is to be generated. Date_of_birth.
grouping level can be added to a report. 9 Figure 66 9 Reports based on grouping levels and sort order will be explained later in the section. NIC. The next screen will appear as shown in Figure 66. To skip grouping option. 78 Training Division. click Next. New Delhi .MS-Access Figure 65 Ø Based on a field.
Figure 67 Ø Ø Select the Report layout as Tabular and orientation as Portrait or Landscape. New Delhi 79 . Figure 68 Training Division. NIC. and you will get the screen as shown in Figure 68. Click on Next.MS-Access Ø If sort order of records is not required. click on Next and you get the screen to decide the layout of the report as shown in Figure 67.
Figure 69 Ø Clicking on Finish. Give title for your report as Employee and select option Preview the report and then select Finish as shown in Figure 69. New Delhi . shows the Preview of the Report as shown in Figure 70 and the report file will be saved with same name as the title of report which can be changed. Figure 70 Report created using wizard option can be modified as and when required by going in design view of that report. 80 Training Division. NIC.MS-Access Ø Ø Select the Style for your report and click Next.
MS-Access E Creating a Report in Design View Ø Ø Ø Ø Ø Ø Ø In the Database window. In the New Report dialog box. Label for the fields should be written in page header and title for the report should be written in the report header. Figure 71 Ø Click View>> Print Preview to get preview of the report as shown in Figure 72. don’t select anything from this list. click Design View. NIC. (If you want an unbound report. Click on New. For example. select table employee . Training Division. Select the name of the table or query and Click OK. Page Header/Footer and Report Header/Footer options are selected by clicking View>>Page Header/Footer and View>>Report Header/Footer as shown in Figure 71.) Click on View>>Field list (if the field list is not visible) and drag the required fields of the table in the detail section of report design view. select Reports object. that contains the data you want to base your report on. New Delhi 81 .
The output of this report will be as shown in Figure 73. 82 Training Division. Ø In the Reports tab of Database window. NIC. Ø Follow the instructions in the wizard dialog boxes. click Label Wizard. New Delhi . Ø In the New Report dialog box.MS-Access Figure 72 E Creating a Report for Mailing Labels This type of report is used to create labels from the database which can be used for the mailing purpose. and then click OK. Ø Select the table or query that contains the data for the labels. click New.
New Delhi 83 . the expression in the text boxes for DA will be =[basic]*0. A report can be sorted on upto a maximum of 10 fields or expressions.42 E Sorting and Grouping Records ö Sort records in a report Records in a report can be arranged in certain order depending on the sorting and grouping order defined.MS-Access Figure 73 E Creating Calculated fields in the Report The calculated fields can be displayed on a report to show the results based on some calculations on a field. Results would be displayed in Print Preview For example. NIC. Training Division. Ø Write the expression for calculation in the Text box. if we have to calculate DA from the Basic of the employee. Ø To include a calculated field. create a text box in the Detail section of the report in the design view.
Ø Either Group Header or Group Footer should be set to ‘Yes’ in order to create a group level. For each field defined in the sorting order. Ø Click on View>>Sorting And Grouping to display the Sorting And Grouping box as shown in Figure 74. · GroupFooter. Ø Ø Click the field or expression whose group properties you want to set. Adds or removes a group footer for the field or expression.MS-Access To create report in the sorted form. NIC. Ø In the first row of the Field/Expression column. sort order can be defined as Ascending or Descending. do the following steps: Ø Open the report in Design view. Figure 74 The field or expression in the first row is the first sorting level (the largest set). · GroupHeader. group properties can be defined. For each sorting level. or type an expression as shown in Figure 74. Adds or removes a group header for the field or expression. The second row is the second sorting level. Set the group properties in the following list. 84 Training Division. select a field name. New Delhi . and so on upto 10 sorting levels can be defined.
MS-Access · · · GroupOn. New Delhi 85 . Figure 75 The design view of the form will be appear as shown in Figure 76. If you group on an expression. Set the group properties as shown in Figure 75. Keep Together. GroupInterval. The options you see depend on the data type of the field on which you’re grouping. Specifies any interval that is valid for the values in the field or expression you’re grouping on. Specifies the value or range of values that starts a new group. NIC. Figure 76 Training Division. you see all the options for all data types. Keeps groups together on one page.
the field on which grouping is to be done should be kept in Group Header section not in Detail section as Designation field is kept in Designation header section. The RunningSum property applies only to a text box and in the Design View of the report. NIC. The output will be appear as shown in Figure 77. select Properties from the option. first select the text box and click the right mouse button. Note : To open text box property sheet. 86 Training Division. New Delhi . Figure 77 E Calculating a Running Sum Running Sum property is used to calculate record-by-record or group-by-group totals in a report.MS-Access Note: When designing a report.
type an expression : = Sum ( [Salary]) in Report Footer as shown in Figure 78. New Delhi 87 .MS-Access ö Ø Ø Ø To calculate running sum in a report Open report in Design View. to calculate total salary given. The output of this report will appear as shown in Figure 79. Create Text Box in the Report Footer. For example. Figure 78 Note: Expression for the running sum can be given for more than one field in report footer. NIC. Training Division. Type Expression in the Text Box created at the Report Footer.
in Report Open report in Design View. 88 Training Division. Set ControlSource Property =1 and set the RunningSum property to Over Group. the expression must be written in the Group footer. NIC. From the property sheet. Create text box in Detail Section of report to calculate a record-by-record total. The Design View of the report appears as shown in Figure 80. ö Ø Ø Ø Ø To include Serial No. New Delhi . click on either Data or All tab.MS-Access Figure 79 Note: If calculation is to be made on Groups.
NIC. place the text box in a group header and in the Text box property sheet.MS-Access Figure 80 The output for this design view appears as shown in Figure 81. Note: To give S. Training Division.NO. New Delhi 89 . groupwise. Figure 81 Ø Save this report as employee_detail. set RunningSum as OverGroup and ControlSource Property = 1.
type the amount of vertical space you want between each record in the detail section. in other words. click Portrait or Landscape. In this case Report Header/Footer and Page Header/Footer span the full width of the report. type the number of columns you want on each page. New Delhi . place the controls in the first three inches of these sections in Design view. You can set the height of the detail section by typing a number in the Height box or by adjusting the height of the section in Design view. 3”. Under Column Size. Note : If you left space between the last control in the detail section and the bottom edge of the detail section. Click the Page tab of the Page Set-up dialog box Under Orientation. in the Number Of Columns box. On the File menu. 90 Training Division. you can leave Row Spacing set to 0. Click OK. click suitable option as shown in Figure 82. Under Column Layout. for example. type the width you want for a column in the Width box. In the Row Spacing box. click the Columns tab. if you want to print the data in two three-inch columns.MS-Access E Different Types of Reports ö Multiple Column Report A multiple-column report can be used to print the report in more than one column. type the amount of space you want between the columns. For example. click Page Setup. while Group Header/Footer and Detail Section span the width of one column. Ø Ø Ø Ø Ø Create a report and open it in Design View. Under Grid Settings. Ø Ø Ø Ø Ø Ø In the Column Spacing box. In the Page Setup dialog box. place the controls within the width of one column. NIC.
MS-Access Figure 82 Print preview of the Report is shown in Figure 83. New Delhi 91 . NIC. Figure 83 Training Division.
Ø In the ColumnHeadings property box. The report thus obtained is shown in Figure 84. enclose it in double (“ “) quotation marks.”El Taken”.MS-Access ö Crosstab Report Cross-tab Report is based on a Cross-tab query meant for analysing the data in a cross-tab format. Ø Add the controls for the fields you want to appear in the report.”Medical Taken” Ø Create a blank report that is bound to the crosstab query. New Delhi . Ø Place text boxes for the row headings and column values in the detail section. Ø In query Design View. you would type: “CL Taken”. Ø Create a Crosstab query. NIC. type the column headings you want to appear in the report. If a column heading contains spaces. separating each one with a semicolon. Figure 84 92 Training Division. For instance. Ø Place labels for the row headings and column headings in the page header. display the query’s property sheet by double-clicking anywhere outside the design grid and outside the field lists. in a query showing sales by quarter.
New Delhi 93 . make the main switchboard page default that will open first when switchboard is run. NIC. Ø Click Yes. The following dialog box will appear as shown in Figure 85. one needs to create a GUI menu (Graphics User Interface menu). reports etc. reports. Figure 85 Following options are available in Switchboard Manager: Close – To close switchboard Manager. New – To add new switchboard Page to Switchboard manager. Various objects can be opened by clicking the various buttons on the Switchboard. Ø Click Tools >> Database Utilities >> Switchboard Manager. Training Division. macros. Edit – To add items to switchboard page.MS-Access q Switchboard and Custom Menus After creating the forms. in the database. Make Default – When switchboard manager has more than one page. modules in the database. reports or other objects already created. It will helps in navigating among the various objects like forms. E Creating a Single Page Switchboard Ø Open the database containing forms.To delete switchboard Page. If switchboard is created for the first time then Microsoft Access asks if you’d like to create a switchboard. Delete .
94 Training Division. NIC. type the text that is to be displayed for the Switchboard Item on the Switchboard page. The dialog box appeared as shown in Figure 86. New Delhi . Figure 86 Ø Click New button to add switchboard items to this page. in the Text: field.MS-Access Ø Click Edit button of Switchboard page (shown in Figure 85) to create all the switchboard items of that page. the next field of the dialog box changes. Depending on the selection of command. Select the Command: to be executed. The dialog box appears as shown in Figure 87. Figure 87 Ø Ø In the Edit Switchboard Item dialog box. Ø Enter the values as shown in Figure 88.
New Delhi 95 . NIC.1 Enter Employee’s Open form in Details add mode 1.2 Enter Leave Details Open form in add mode 1.4 1.3 Employee report Open report 1. Table 1 shows the various items that can be added to this page.5 Leave detail report of an employee Exit Employee (Form name) Leave (Form name) Employee (Report name) Open Report Leave_detail (report name) Exit Application — — — — Table 1 : Switchboard items and their commands in Single page Switchboard Ø Ø Click Close. Training Division.MS-Access Figure 88 Ø Click OK. Click Close Button of the Switchboard Manager Dialog box. after adding all the switchboard items to the Edit Switchboard Page. SN SWITCHBOARD SWITCHBOARD PAGE PAGE ITEMS COMMANDS OBJECTS TO BE EXECUTED 1 Main Switchboard 1. More items can be added to this Switchboard by clicking on New button in the Edit Switchboard Page dialog box and entering the information as done for the previous item. You come back to database window.
New Delhi . Select Switchboard form. one form named Switchboard and a table named Switchboard items will appear in the database window in their respective objects. NIC. Click on Open. Default Main Switchboard page will opened as shown in Figure 89. The Switchboard page for the above items will be appeared as shown in Figure 89. 96 Training Division. Switchboard Page Switchboard Page Items Figure 89 Running the Switchboard Ø Ø Ø Click on Forms object in the database window.MS-Access Once the Switchboard is made.
If switchboard is created for the first time then Microsoft Access asks if you’d like to create a switchboard. add all the Switchboard Pages to Switchboard Manager by clicking New button. Click OK. Ø Similarly. New Delhi 97 . the dialog box appeared as shown in Figure 90. A new page is added to the Switchboard manager. Training Division. The Switchboard Manager dialog box with all pages included will appear as shown in Figure 91.MS-Access E Creating a Multiple Page Switchboard Note: If more than one switchboard pages is required. NIC. Click New in the Switchboard Manager Dialog box to add new page. The Switchboard Manager dialog box appears as shown in Figure 85. Ø Click Tools >> Database Utilities >> Switchboard Manager. then first create all the pages in the Switchboard Manager dialog box. Figure 90 Ø Ø Type the Name of the New Switchboard Page. Ø Ø Click Yes.
New Delhi . Figure 92 98 Training Division. NIC.MS-Access Figure 91 ö Ø Ø To add items to the switchboard page Select the Switchboard page in which Items has to be added. The Edit Switchboard dialog box will appear as shown in Figure 92. Click Edit in the Switchboard Manager dialog box to edit all the items in that page. For example. select Main Switchboard page.
do the following settings. Text/List box name Text Command Switchboard Value Maintain Employee’s Data Go to Switchboard Update Employee Ø Click OK after doing all the settings as shown in Figure 93. New Delhi 99 .MS-Access Ø Ø Click New. In the Edit Switchboard Item dialog box. The page containing all the items will be appears as shown in Figure 94. NIC. Figure 94 Training Division. Figure 93 Add rest of the items to the same switchboard by following the above three steps.
Click the item in the Items On This Switchboard box.MS-Access Ø Ø Click Close. Similarly add all the items to the rest of the pages of the Switchboard. Click the item in the Items On This Switchboard box. Click Move Up or Move Down to change the order of the item. Click Edit or Delete depending on the requirement. NIC. ö Ø Ø Ø To rearrange items Open the switchboard page in Edit mode. New Delhi . ö Ø Ø Ø Edit or Delete items Open the switchboard page in Edit mode. Note: Block Diagram and Table 2 are provided in the following pages to add all switchboard items and their commands for all switchboard pages. 100 Training Division.
Reports) 5) Exit ( To exit from an application) 4) Add New Employee ( To open Employee form in Add mode) 5) Modify Employee Data ( To open Employee form in Edit mode) 6) Delete Employee Data ( To run Macro.MS-Access Block Diagram for Multiple Page SwitchBoard Update Employee Page Main SwitchBoard Page Page Items 1) Maintain Employees Data ( To open New Switchboard Page. New Delhi 101 . Macro_Delele_emp_Records) Reports Page 4) Employee Report (To open Report Employee ) 5) Creating Employee Label ( To open report Employee Label ) 6) Leave Details of Individual employee ( To open report Leave ) Training Division. NIC. Update Employee) 2) Enter Leave Details ( To open Leave Form) 3) Year End Processing ( To Run Macro) 4) Reports ( To open new switchboard page.
MS-Access SN SWITCHBOARD SWITCHBOARD PAGE PAGE ITEMS COMMANDS OBEJCT TO BE EXECUTED 1 Main Switchboard 2 Update Employee’s Detail Maintain Employee’s Data Enter Leave Details Year End Processing Reports Exit Add New Employee Modify Employee Data Delete Employee Records Exit Employee Report Creating Employee Labels Exit Goto Switchboard Update Employee’s Detail Open form in Leave Edit Mode Run Macro Goto Switchboard Reports Exit Application Open form in Employee Add Mode Open form in edit mode Run Macro employee 3 Report Macro_Delele_ emp_Records Go to switchboard Main Switchboard Open Report employee Open Report Labels employee Go to Switchboard Main Switchboard Table 2 : Switchboard items and their commands in Multiple page Switchboard 102 Training Division. New Delhi . NIC.
Figure 95 Ø Click on the appropriate button to execute the command.MS-Access Running Multiple Page Switchboard Ø Ø Ø Click on Forms object. Default Main Switchboard page will open first as shown in Figure 95. New Delhi 103 . Click on Open. NIC. Training Division. Select Switchboard form.
For example. Training Division.gif. New Delhi 104 . c:\Program Files\Microsoft Office\Office\Bitmaps\Dbwiz\ledger. It will be appeared as shown in Figure 96. Figure 97 Ø Click on the Picture property.MS-Access E Adding Picture to the Switchboard Ø Open the Switchboard form in Design mode. following dialog box will appear as shown in Figure 97. specify the picture file name with complete path. Press Right mouse button in this portion Figure 96 Ø Press right mouse button and select properties option. NIC.
NIC. dialog box as shown in Figure 99 will appear. Figure 98 E Deleting a Switchboard To delete Switchboard from the access database Ø Delete Switchboard Items table from tables object. New Delhi 105 . E Making Switchboard Page as a Startup Object The Switchboard can be kept in such a way that when the database is opened. Ø Delete Switchboard form from the form objects.MS-Access The picture will be added to the switchboard as shown Figure 98. Ø Click Tools>>Startup. Training Division. Switchboard open first and from their the items can be selected.
106 Training Division. New Delhi .MS-Access Figure 99 Ø Give application title name and in Display Form/Page option give default Switchboard page name as shown in Figure 100. NIC. Figure 100 Ø Click OK.
MS-Access E Creating Custom Menus Open database to which Custom Menu is to be added. Ø Click View >> Toolbars>> Customize. Type Main menu in the text box in New Toolbar dialog box as shown in Figure 102. 107 Training Division. Figure 101 Ø Ø Click Toolbars tab (If it is not already active) and choose New. NIC. New Delhi . Figure 102 Ø Click OK. Customize dialog box will appear as shown in Figure 101.
Select Menu Bar in the Type list box as shown in Figure 103. New Delhi . Click on Properties button.MS-Access Item Main menu will be added to the Toolbars list. if not already selected. 108 Training Division. Figure 103 Selecting Menu Bar in the Type: box creates Main menu with no items and it appears on screen as shown in Figure 104. NIC. Ø Ø Ø Select Main menu option from Toolbars. Figure 104 Ø Close the Toolbar Properties dialog box.
Select New Menu as shown in Figure 105. New Delhi 109 .MS-Access ö Ø Ø To add items to this menu bar Click Commands tab in Customize dialog box. Figure 106 Similarily add all items to custom menu as shown in Figure 107. Figure 105 Ø Ø Drag New Menu from the command list to the Main menu menu bar. NIC. Right click on New Menu in the Main menu and type Update Employee in the Name text box as shown in Figure 106. Training Division.
The Main menu designed is shown in Figure 108. drag the command Leave and rename it as Leave Details. ö Ø Ø Ø To add commands to it In the Customize dialog box. 110 Training Division. NIC. Ø Click All Macros from Categories. add items to Year End Processing and Reports menu options. if not already selected. An empty box will appear. Drag the command employee to the empty box and rename it as Add Employee. Figure 108 Similarily other items can be added to the various menu options. Click All Forms from Categories. select Command tab. The forms would now be added to this. click Update Employee menu option. Similarly.MS-Access Figure 107 Ø In Main menu. Ø Drag the macro designed for deleting records and rename it as Delete Employee. For example. New Delhi .
MS-Access E Making Custom Menu as a Startup Object Ø Ø Click Tools>>Startup. NIC. Main menu will appear as shown in Figure 110. select Main menu in the Menu Bar text box as shown in Figure 109. New Delhi 111 . Figure 109 Ø Click OK. When database is opened. In the Startup dialog box. Figure 110 Training Division.
Database title bar Figure 111 Ø Ø Click on Startup option and change the setting of the Menu Bar to Default. New Delhi . Popup menu will appear as shown in Figure 111. NIC. Default menu bar will appear again. Ø Point your mouse cursor to the database title bar and Click right mouse button. 112 Training Division. Close this application and when you open database again.MS-Access E Restoring Default Menu For restoring the default database menu bar.
and text file formats with the help of built-in drivers or ODBC drivers10 . Importing. Microsoft IIS 10. E Exporting Exporting is a way to output data and database objects to another database. application. ODBC databases 11. Linking and Exporting are the different ways used for the exchange of data in MS Access. Foxpro 5. HTML documents 6. spreadsheet. or program can use the data or database objects. The various types to which they can be exported are: 1. New Delhi 113 . Text Files 8. Paradox 7. spreadsheet. Excel 4. or file format so that another database. Rich Text Format 9. Dbase 3.MS-Access q Importing and Exporting Data Importing and exporting data helps in exchanging data from a number of different databases. Microsoft Word Merge 10 For details refer to Annexure III Training Division. NIC. Microsoft Access 2.
114 Training Division. Click Save. Select the Table/Query which is to be exported. NIC. New Delhi .MS-Access Steps for Exporting data Ø Ø Ø Open the Access Database Employee created earlier. Figure 112 Ø Ø Specify the file name as Leave and the type as Microsoft Excel 97-2000. to which it is to be exported. Click File>>Export. Following dialog box will appear as shown in Figure 112. in the respective text boxes. Thus the data of the Leave table gets exported to an Excell worksheet named Leave. in this case select Leave.
you can’t append data to existing tables (except when importing spreadsheet or text files). The source table or file is not altered in this process. However. Training Division. Any changes in Excel file will not be reflected in data stored in MS-Access table/Query. E Importing Importing data creates a copy of its information in a new table in your Access database or Access project. once you have imported a table. The various types from which data can be imported are: · Microsoft Access · Dbase · Excel · Foxpro · HTML documents · Paradox · Text Files · Rich Text Format · ODBC databases · Exchange 11 12 An action query that adds the records in a query’s result set to the end of an existing table. from another Access database or Access project. and allow user-declared variables. conditional execution. Stored procedures are stored in an SQL database such as Microsoft SQL Server. NIC. usually on a server. A precompiled collection of SQL statements and optional control-of-flow statements stored under a name and processed as a unit. You can also import database objects other than tables. and other powerful programming features. in an Access database you can perform an append query11 or in an Access project you can use a stored procedure12 to add the table’s data to another table. can be run with one call from an application. in the same manner. When importing data. New Delhi 115 . such as forms or reports.MS-Access Now this file can be opened in Ms-Excel for further editing. Note : The data from Access can be exported to other file formats. selecting the Save As type for the desired format. specified earlier.
Depending on the type of the file from which data is to be imported. if data is imported from an Access database. Click Import. For example. Following dialog box will appear as shown in Figure 113. the further options have to be chosen. 116 Training Division. Figure 113 Ø Ø Select the type of file and the name of file from which data is to be imported. New Delhi . following window will appear as shown in Figure 114. Click File>>Get External Data>>Import. NIC.MS-Access Steps for Importing data Ø Ø Open the Access Database.
Ø · · · · · · Ø Click OK. Click Finish. Training Division. Foxpro. then table name. Whether the data is to be imported in a new table or existing ones. Specify the field option for all fields. Information about primary key. For example. Rich Text Format. Excel. HTML documents. Microsoft Access. If it is an Excel file then a 6-step wizard will start which will ask for the following options: Worksheet or Range to be imported. Paradox. Similar steps with minor differences can be followed for other types of files. New Delhi 117 . Dbase.MS-Access Figure 114 The various objects of the database are listed and the data desired from any of these objects can be selected. ODBC databases. If it is a new table. Text Files. Exchange. Specify whether first row of data contains column headings or not. NIC.
delete. or edit its data by using Microsoft Access as well. for example if Excel sheet is linked then icon will be . under the Tables object tab and other tables that are stored in the current database. Microsoft Access uses different icons to represent linked tables. linking data enables you to read and in most cases.. but you can add. If you delete the icon for a linked table.. cannot be altered since it is linked with the source. You can link a table only in an Access database. New Delhi . NIC. not the external table itself. not in an Access project. Ø Click Link. The external data source’s format is not altered so that you can continue to use the file with the program that originally created it. Note: The design of the table. Linking is done by Ø Select File >> Get External Data >> Link Tables. update data in the external data source without importing. you delete the link to the table.MS-Access E Linking In an Access database. thus linked. Link dialogue box appears where file name and File type can be specified. 118 Training Division.
6. 6. II. Choose appropriate folder. Select already created Excel file in step 1. Importing data from Excel Worksheet to MS Access 1. Right click on database and select Import option. Save the Excel Worksheet . View the newly created table. Name. 3. 2. Open Employee database in MS Access. Through Wizard select appropriate options and create a new table with data picked up from Text file. Select already created text file. Importing text file to MS Access 1.MS-Access E Assignments I. Create a simple Excel Worksheet with first row as field names and five rows filled with some data ( E-code. 3. New Delhi 119 . 4. 5. and type of file as “Text”. 7. Choose appropriate folder and type of file as “Excel”. qualification. Through Wizard make appropriate selections and create a new table containing data from Excel Worksheet. designation. 5. 4. 7.”. Training Division. Create a file using Notepad containing data items separated by “. Open already existing Database ( say employee) through MS Access. Controlling Officer) 2. Right click on database and select Import option. NIC.
Repeat the above steps with a Query already created in database Employee. V Click on File>>Export. 3.MS-Access III. Choose table Employee. Choose an already created report. Select file type as HTML and click Save. 2. Open database Employee. View the new file in MS Excel . Exporting Data from a table/Query to Excel Worksheet 1. 5. Publishing MS Word / MS Excel Report to MS Word/Excel file 1. IV Exporting data from a table / query to HTML page 1. New Delhi . View the new file through Internet Explorer or MS Word. Repeat the above steps with a Query already created in database Employee. 5. NIC. Choose table (say employee table). 2. Select file type as MS Excel and click Save. 4. 120 Training Division. Click on File>>Export. 6. 4. 3. Open database Employee. Open database employee. 2. 6.
which appears as shown in Figure 116. Open Database in MS Access. Choose the option Create a new document / link your data to an existing word document. Select the table / query from which you want to merge fields in a MS Word document. 5. 4. 2. 3. Click on office links on the toolbar as shown in Figure 115. Training Division. New Delhi 121 . Now you may generate letter.MS-Access 3. Click on option Publish it with MS Word / Analyse it with MS Excel View the newly created Word / Excel file. 6. Office links Figure 115 4. From the office links dropdown list select the option Open MS Word Document. and insert fields from the special Mail Merge window. NIC. type the matter. In the MS Word window. VI Mail Merge in MS Word with data from MS Access table /Query 1.
New Delhi . NIC.MS-Access Figure 116 122 Training Division.
MS-Access q Annexure I Various Data Types are given in the following table Data Type Text Description holds text up to 255 characters. Date/Time holds date and time. depending upon the format you give to it in the field properties panel. Currency holds number used as amounts of money. which you can display simply by clicking the field. You can enter Date/Time on the format you select for the field. AutoNumber holds sequential numbers that Access automatically enters.1 . True/False or On/Off. defined as Yes/No. Memo holds text up to 65000 characters. Lookup Wizard lets you create a lookup field where user chooses values from the list of values entered or taken from the table. numbers and special characters. document or web page. is of variable length: you do not specify a maximum size for it. Sound Files or any other type of data available from Windows applications that supports OLE. New Delhi A 1. This field can be used to attach pictures. Training Division. OLE Object holds data from other Window application that support object linking and embedding. NIC. Hyperlink holds the address of an object. Number holds numeric data. including letters. Yes/No holds two values.
Figure 117 Training Division. Field properties area is shown in Figure 117. Note : The field properties area of the table design window shows only one field property at a time. Different data types offer different properties.1 . Make sure that the arrow symbol should appear before the selected field.MS-Access q Annexure II E Field Properties Field properties can be changed by using the options on the General and Lookup tabs in the field properties pane in the table design window. NIC. New Delhi A 2.
Time. Number.678 in the control. Caution : If you convert a large FieldSize setting to a smaller fieldsize that already contains data. For example. the number would be displayed as $4.MS-Access General Field Properties ö Field Size FieldSize property is used to set the maximum size for data stored in a field set to the Text.2 Training Division. Settings: Data Type Text AutoNumber Number Default Setting 50 Long Integer Long Integer Settings Allowed Number from 0 to 255 Long Integer or Replication Id Byte Decimal Integer Single Double Replication Size 4 Byte 1 Byte 12 Byte 2 Byte 4 Byte 8 Byte 16 Byte Note : Use the smallest possible FieldSize property setting because smaller data sizes can be processed faster and require less memory. and Text are displayed and printed.321. NIC. Date. A 2. New Delhi . in a Price text box. If you enter 4321. or AutoNumber data type. ö Format Format property is to customize the way in which Numbers.68. you might lose data. its Format property is set to Currency and its Decimal Places property to 2 or Auto.
Display the next character as a literal character. Display the formatted data in the color specified between the brackets. Red. New Delhi A 2. Green. ö Input Mask InputMask property is used to make data entry easier and to control the values. Yellow. It doesn’t affect how data is stored. exactly how to enter a new number: (___) ___-____. Magenta. Fill available space with the next character. White. Display anything inside quotation marks as literal characters. Blue.MS-Access The Format property provides different settings for different data types. Available colors: Black. Following symbols can be used in custom formats for any data type: Symbol (space) “ABC” ! * \ [color] Meaning Display spaces as literal characters. Force left alignment instead of right alignment. For example. an input mask for a Phone Number field that shows. You can also display literal characters by placing quotation marks around them.3 . · Date/Time Data Type · Number and Currency Data Types · Text and Memo Data Types · Yes/No Data Type Note : The Format property affects only how data is displayed. NIC. users can enter in a text box control. Cyan. Training Division.
entry required. plus and minus signs not allowed). L ? A a & C . Causes the character that follows to be displayed as the literal character (for example.MS-Access An input mask can be defined by using the following characters: Character 0 9 # Description Digit (0 to 9. Decimal placeholder and thousand. New Delhi . spaces are displayed as blanks while in Edit mode. Causes the input mask to display from right to left. entry required). Any character or a space (entry required). Letter (A to Z. Causes all characters to be converted to uppercase.-/ < > ! \ Note : Setting the InputMask property to the word Password creates a passwordentry control. entry optional). plus [+] and minus [–] signs not allowed). You can include the exclamation point anywhere in the input mask. Digit or space (entry not required. and time separators. A 2. Letter or digit (entry required). date. Causes all characters to be converted to lowercase. NIC. but blanks are removed when data is saved.:. plus and minus signs allowed). (The actual character used depends on the settings in the Regional Settings Properties dialog box in Windows Control Panel). \A is displayed as just A). Digit or space (entry not required.4 Training Division. Any character or a space (entry optional). Letter (A to Z.. Characters typed into the mask always fill it from left to right. Letter or digit (entry optional). Any character typed in the control is stored as the character but is displayed as an asterisk (*). rather than from left to right.
For Example. Training Division. Form captions specify the text that appears in the title bar in Form view.5 .MS-Access The following table shows some useful input masks and the type of values can be entered: Input mask (000) 000-0000 (999) 999-9999 (000) AAA-AAAA #999 >L????L?000L0 >L0L 0L0 00000-9999 >L<?????????????? SSN 000-00-0000 >LL00000-0000 Sample values (206) 555-0248 (206) 555-0248 or ( ) 555-0248 (206) 555-TELE –20 or 2000 GREENGR339M3 or MAY R 452B7 T2F 8M4 98115. New Delhi A 2. Field Name Emp_code Ename Caption Employee Code Employee Name The result with these caption is shown in Figure 118. Report captions specify the title of the report in Print Preview.or 98115-3007 Maria or Brendan SSN 555-55-5555 DB51392-0493 ö Caption Caption property provides helpful information to the user through captions on objects in various views: Field captions specify the text for labels attached to controls created by dragging a field from the field list and serves as the column heading for the field in table or query Datasheet view. NIC.
For example. to display “Save & Exit”. option button. type Save && Exit in the Caption property box. NIC. When users add a record to the table. New Delhi . è Default Value DefaultValue property is to specify a value that is automatically entered in a field when a new record is created. in an Addresses table you can set the default value for the City field to New York. or toggle button controls when they are in an option group.6 Training Division. For example. A 2.MS-Access Caption appeared as column Heading in Datasheet view Figure 118 Note : Include two ampersands (&&) in the setting for a caption if you want to display an ampersand itself in the caption text. It does apply to the option group itself. Note : · The DefaultValue property doesn’t apply to check box. they can either accept this value or enter the name of a different city.
New Delhi A 2. Standard error message will be displayed. They apply only to the option group itself. field. A ValidationRule property can be set for the employee’s Salary field to be >0. When data is entered that violates the ValidationRule setting.” Training Division.Enter an expression – Maximum length 2048 Character. or toggle button controls when they are in an option group. For example. option button. Ø Ø In ValidationRule .MS-Access · The DefaultValue property applies to all table fields except those fields with the data type of AutoNumber or OLE Object. Default values that can be assigned to a field Default Value =Date() =Now() 0 Yes No CA Value Today’s date Current date and Time Number zero True No Letter CA Data Type Date/Time Date/Time Number or Currency Yes/No Yes/No Text ö ValidationRule and ValidationText Properties The use of ValidationRule property is to specify requirements for data entered into a record. NIC.7 If ValidationRule property – Set . ValidationText property is Not Set. ValidationText property is Set. ValidationText property can be used to specify the message to be displayed to the user. text entered will be displayed as the error message. It display the ValidationText property message: “Salary must be greater than zero. or control. In ValidationText – Enter a Text – Maximum length 255 Character. If Salary is Less than or equal to Zero. Note: The ValidationRule and ValidationText properties don’t apply to check box.
Note : The AllowZeroLength property applies only to Text. NIC. Memo. add “Is Null” to the validation rule. (Default) A zero-length string is an invalid entry. Microsoft Access doesn’t normally allow a Null value to be stored in the field. and Hyperlink table fields. Entry must be a unique CustomerID “Customers”.MS-Access Examples for the ValidationRule and ValidationText properties: ValidationRule property <> 0 > 1000 Or Is Null Like “A????” ValidationText property Entry must be a nonzero value. Entry must be 5 characters and begin with the letter “A”. as in “<> 8 Or Is Null” and set Required property to NO. >= #1/1/96# And <#1/1/97# Entry must be a date in 1996.8 Training Division. The AllowZeroLength property uses the following settings: Setting Yes No Description A zero-length string is a valid entry. Entry must be blank or greater than 1000. If you want to allow a Null value. Note : If validation rule is set for a field. DLookup(“CustomerID”. New Delhi . è Allow Zero Length property AllowZeroLength property is used to specify whether a zero-length string (“ “) is a valid entry in a table field. A 2. “CustomerID = Forms! (domain aggregate functions are allowed Customers!CustomerID”) Is Null only for form-level validation).
Note: The Required property doesn’t apply to AutoNumber fields. New Delhi . search for specific employee names in a eName field of employee table. An index speeds up queries on the indexed fields as well as sorting and grouping operations. Results from combined settings of the Required and AllowZeroLength properties are: Required No AllowZeroLength User’s action No Presses ENTER Presses SPACEBAR Enters a zero-length string Yes Presses ENTER Presses SPACEBAR Enters a zero-length string No Presses ENTER Presses SPACEBAR Enters a zero-length string Yes Presses ENTER Presses SPACEBAR Enters a zero-length string Value stored Null Null (not allowed) Null Null Zero-length string (not allowed) (not allowed) (not allowed) (not allowed) Zero-length string Zero-length string No Yes Yes ö Indexed Property Indexed property is used to set a single-field index. If this property is set to Yes. The Indexed property uses the following settings: Setting No Yes (Duplicates OK) Yes (No Duplicates) Description (Default) No index. then it is must to enter the value in that field. NIC. A 2. The index doesn’t allow duplicates.MS-Access ö Required Property Required property is used to specify whether a value is required in a field. For example. create an index for this field to speed up the search for a specific name.9 Training Division. The index allows duplicates.
If the primary key for a table is a single field. For example. Lookup Properties To open lookup property sheet Ø Switch to the design view of table. Ø Click the Lookup tab in field property area.MS-Access Remarks Use the Indexed property to find and sort records by using a single field in a table. an index on an Emp_code field in an Employee table in which each emp_code is unique or create an index on a eName field in which some names may be duplicates. Microsoft Access will automatically set the Indexed property for that field to Yes (No Duplicates). of fields in table. The indexes are created when table is saved and are automatically updated when records are changed or added. Hyperlink. New Delhi .10 Training Division. If Designation field is created as lookup field. NIC. Indexed property can be added or deleted any time in table Design view. Index can be created to any no. The field can hold either unique or non-unique values. Ø Select field. it will appear as shown in Figure 119. Note : Indexed property is not applicable to Memo. or OLE Object data type fields. Figure 119 A 2.
Column Count This property specifies how many columns to display. Bound Column This control is used to specify which column in the row source contains the value to store in lookup fields.MS-Access In datasheet view lookup field will be appeared as shown in Figure 120.e. the list box contains two columns but it will store the second column value in designation field so bound column value is 2. In the above figure the row source is value typed. Row Source Lets you choose the source of the control’s data. To show column headings change setting to Yes. New Delhi A 2. Column Heads This property is used to choose whether to show column headings. As shown in above figure. Training Division. set property to List Box or Combo Box for Lookup fields) Row Source Type This control is used to choose the source of data in the fields(Table/ query. NIC.11 . By default no column headings appear. Value List or Field List). Figure 120 Different options in Lookup properties are: Option Display Control Description This control is used to display the fields in Datasheet View (i.
If set to No. entries allowed that are not in drop-down list. only values shown in drop down list are allowed during data entry. A 2.MS-Access Column Widths List Rows List Width Limit to List It is used to specify the width of each column shown in drop down list. It specifies the width of entire combo box.12 Training Division. NIC. New Delhi . If set to Yes. It specifies how many rows to display in the drop down list at once (by default is 8).
MS-Access q Annexure III E Built-in drivers and ODBC drivers ö Built-in drivers are available when you use the l l Export command on the File menu. Microsoft FoxPro databases.1 Training Division. Double click on the ODBC icon in the control panel. the Oracle ODBC driver (msorcl32. All built-in drivers are installed automatically when you install Access. Microsoft Access automatically installs the Microsoft SQL Server ODBC driver (Sqlsrv32. Ø ODBC (32bit) icon is available in Control Panel. or l In the Files Of Type box in the Import or Link dialog boxes. Data from other programs that provide 32-bit drivers in compliance with ODBC Level 1 to access their data files. Ø Files Of Type box on the Import or Link dialog boxes. New Delhi .dll). and some ODBC support files (Help files and the Control Panel ODBC (32bit) icon). NIC. ö ODBC drivers are used to connect to l l Microsoft SQL Server databases. l Save As Type box in the Export Object ‘Object Name’ To dialog box.dll). ODBC datasource administrator wizard as shown in Figure 121 will start: A 3. the FoxPro ODBC driver (vfpodbc.dll). The ODBC Databases option is available in the Ø Save As Type box in the Export Object ‘Object Name’ To dialog box. ö Ø Ø How to create ODBC data source On the Windows desktop click Start>>Settings>>Control Panel. The Import and Link Tables commands on the Get External Data submenu on the File menu.
Click Add. Training Division. as shown in Figure 122. New Delhi A 3.2 .MS-Access Figure 121 Ø From the screen appeared in Figure 121. NIC. Data Source Name will be listed in the ODBC database Administrator which can be used later on. Click OK. Figure 122 Ø Ø Specify the Data Source Name and select the database name by clicking on Select button. select the driver name.
Getting Started with MS-Access
Government of India Ministry of Communications & Information Technology Department of Information Technology National Informatics Centre Training Division New Delhi
Getting Started with MS-Access Government of India Ministry of Communications & Information Technology Department of Information Technology National Informatics Centre Training Division New Delhi .
I q An Overview of Database Management System Components of an Information System Conventional Approach for Data Management Database Approach Types of Data Model Types of Database Architecture Database Management System Getting Started with Database Design Getting Started with MS-Access …1 q q Case Study Starting MS Access Ways of Creating a Table Creating New Table Saving the Table Adding Records to a Table Deleting Records Editing Data in Tables Sorting Data Modifying Table Design Primary Key Creating Second Table …16 …20 .Contents PART .
q Relationships How it works? Creating New Relationships Editing the Existing Relationship …31 q Query Simple Query Performing Calculation in the Query Using Criteria or Advanced Filters to retrieve certain Records Parameter Queries Action Queries More about Queries Accessing Query through Form …39 q Forms Creating a Form using Wizard Creating a Form in Design View Different Controls Further Enhancements in Form Design …59 q Reports Creating a Report using Wizard Creating a Report in Design View Creating a Report for Mailing Labels Creating Calculated fields in the Report Sorting and Grouping Records …76 .
113 q Annexures ...Calculating a Running Sum Different Types of Reports q Switchboard and Custom Menus Creating a Single Page Switchboard Creating a Multiple Page Switchboard Adding Picture to the Switchboard Deleting a Switchboard Making Switchboard Page as a Startup Object Creating Custom Menus Making Custom Menu as a Startup Object Restoring Default Menu …93 q Importing and Exporting Data Exporting Importing Linking Assignments .
(iv) The button to be selected appears in Bold font and the selection is through clicking the mouse. (ii) (iii) The options/sub options to be selected or the messages given by the system. if any. This means that first click on the File menu and then click on the sub option New from its drop down menu. For example : Ø Switch on the Computer. which can be skipped by the first timers. is mentioned in the boxes. the user has to perform. (vi) Additional information. For example : Ø Select the File >> New option. For example : Ø Click the Cancel Button. appear in the Bold font. Kindly note that these work books are designed for self learning. For example : Ø Type My First File. (v) The keys to be pressed on the keyboard are shown in Italic font. It is therefore important that you follow the sequence of steps given in the work book.MS-Access A Word with the Participant The conventions followed in this workbook are given below: (i) The steps/commands. are preceded by the symbol Ø. New Delhi . NIC. For example : Ø Press the Enter key. Happy Learning!!! (NIC Faculty) Training Division. if desired. The matter to be typed by the user appears in this typeface.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.