Basics of MS Access

Embed Size (px)

Citation preview

  • 8/2/2019 Basics of MS Access

    1/41

    Basics of MS Access

  • 8/2/2019 Basics of MS Access

    2/41

    What is a database ?

    It's an organized collection of data. A databasemanagement system (DBMS) such as Access,FileMaker Pro, Oracle or SQL Server provides

    you with the software tools you need to organizethat data in a flexible manner.

    It includes facilities to add, modify or delete datafrom the database, ask questions (or queries)about the data stored in the database and

    produce reports summarizing selected contents.

    http://databases.about.com/gi/dynamic/offsite.htm?site=http://www.microsoft.com/accesshttp://databases.about.com/gi/dynamic/offsite.htm?site=http://www.filemaker.comhttp://databases.about.com/gi/dynamic/offsite.htm?site=http://www.oracle.comhttp://databases.about.com/gi/dynamic/offsite.htm?site=http://www.microsoft.com/sqlhttp://databases.about.com/gi/dynamic/offsite.htm?site=http://www.microsoft.com/accesshttp://databases.about.com/gi/dynamic/offsite.htm?site=http://www.filemaker.comhttp://databases.about.com/gi/dynamic/offsite.htm?site=http://www.oracle.comhttp://databases.about.com/gi/dynamic/offsite.htm?site=http://www.microsoft.com/sqlhttp://databases.about.com/gi/dynamic/offsite.htm?site=http://www.microsoft.com/sqlhttp://databases.about.com/gi/dynamic/offsite.htm?site=http://www.oracle.comhttp://databases.about.com/gi/dynamic/offsite.htm?site=http://www.filemaker.comhttp://databases.about.com/gi/dynamic/offsite.htm?site=http://www.microsoft.com/access
  • 8/2/2019 Basics of MS Access

    3/41

    Ms Access

    Microsoft Access provides users with one of thesimplest and most flexible DBMS.

    Microsoft Access is a powerful program to createand manage your databases. It has many built infeatures to assist you in constructing and viewingyour information.

    Three of the major components of Access thatmost database users will encounter

    Tables

    Queries Forms

  • 8/2/2019 Basics of MS Access

    4/41

    MS Access allows you to manage all yourinformation from a single database file.

    Its a Relational Database ManagementProgram or RDBMS.

    RDBMS is a set of two dimensional tables inwhich the data is represented in rows andcolumns.

    A relationship between the tables can be build.

  • 8/2/2019 Basics of MS Access

    5/41

    Some keywords involved in this process are:Database File,Table, Record, Field, Data-type. Here is the Hierarchy thatMicrosoft Access uses in breaking down a database.

    Database File:This is your main file that encompasses theentire database and that is saved to your hard-drive orfloppy disk.Example) StudentDatabase.mdb

    Table:Atable is a collection of data about a specific topic.There can be multiple tables in a database.

    Example #1) StudentsExample #2) Teachers

    Field:Fields are the different categories within a Table.Tables usually contain multiple fields.Example #1) Student LastName

    Example #2) Student FirstName Datatypes:Datatypes are the properties of each field.Afield only has 1 datatype.FieldName- Student LastNameDatatype -Text

  • 8/2/2019 Basics of MS Access

    6/41

    Tables Holds information.

    Forms Allows you to view prints and Edit theinformation.

    Reports Used for summary and printing data.

    Queries Allows you to extract information fromdatabase.

    Macros Lets you perform common tasks withouthuman intervention.

    To create a blank database click on New Database

  • 8/2/2019 Basics of MS Access

    7/41

    Starting Microsoft Access

    Two Ways

    1.Double click on the Microsoft Accessicon on the desktop.

  • 8/2/2019 Basics of MS Access

    8/41

    2.Click on Start --> Programs --> Microsoft Access

  • 8/2/2019 Basics of MS Access

    9/41

    Creating New, and Opening Existing Databases

    The above picture gives you the option to: Create a New Database from scratch Use the wizard to create a New Database Open an existing database

    The white box gives you the most recent databases you have used. If you do notsee the one you had created, choose the More Files option and hit OK. Otherwisechoose the database you had previously used and click OK.

  • 8/2/2019 Basics of MS Access

    10/41

    Create a database using the Database Wizard-When Microsoft Access first starts up, a dialog box

    is automatically displayed with options to create anew database or open an existing one. If this dialogbox is displayed, click Access Database Wizards,pages, and projects and then click OK.

    If you have already opened a database or closed thedialog box that displays when Microsoft Accessstarts up, click New Database on the toolbar.

    -On the Databases tab, double-click the icon for thekind of database you want to create.

    Specify a name and location for the database. Click Create to start defining your new database

  • 8/2/2019 Basics of MS Access

    11/41

    Tables : A table is a collection of data about a specific topic, such as

    students or contacts. Using a separate table for each topicmeans that you store that data only once, which makes yourdatabase more efficient, and reduces data-entry errors.

    Tables organize data into columns (called fields) and rows (calledrecords).

  • 8/2/2019 Basics of MS Access

    12/41

    Tables Datasheet View Design View

    Table Wizard Import Table

    Link Table

  • 8/2/2019 Basics of MS Access

    13/41

    Create a Table in Design view

  • 8/2/2019 Basics of MS Access

    14/41

    1.Double-Click on "Create table in Design view".

    (DESIGN VIEW)

  • 8/2/2019 Basics of MS Access

    15/41

    Define each of the fields in your table. Under the Field Name column, enter the categories of

    your table.

    Under Data Type column, enter the type you want foryou categories. The attribute of a variable or field that determines

    what kind of data it can hold. For example, in aMicrosoft Access database, the Text and Memo fielddata types allow the field to store either text ornumbers, but the Number data type will allow the fieldto store numbers only. Number data type fields storenumerical data that will be used in mathematicalcalculations. Use the Currency data type to display orcalculate currency values. Other data types are

    Date/Time, Yes/No, Auto Number, and OLE object(Picture).

  • 8/2/2019 Basics of MS Access

    16/41

    Under the Description column, enter the

    text that describes what you field is.(This field is optional).

    Example:

  • 8/2/2019 Basics of MS Access

    17/41

    Create table in Design view

    Field Name - Column

    just type the name

    of each field.

    Data type - From the

    Drop down select

    the data type. Description - Give the

    description of the field

    if required for reference.

    Primary Key

  • 8/2/2019 Basics of MS Access

    18/41

    Data Types

    Text - Holds upto 255 Characters Numbers - Holds numbers used in calculations. Date / Time - Holds date and Time Currency - Holds numbers used as amounts of

    currency. Auto Number - Holds sequential numbers which

    are entered by Access. Yes / No - Holds only two values. Hyper Link - Holds the address of an object,

    document or Web page.

  • 8/2/2019 Basics of MS Access

    19/41

    Primary Key One or more fields (columns) whose value or values

    uniquely identify each record in a table. A primarykey does not allow Null values and must always have aunique value. A primary key is used to relate a tableto foreign keys in other tables.

    NOTE: You do not have to define a primary key, butit's usually a good idea. If you don't define a primarykey, Microsoft Access asks you if you would like tocreate one when you save the table.

    Make the Soc Sec # field the primary key, meaningthat everystudent has a social security number andno 2 are the same. To do this, simply select the Soc Sec # field and

    select the primary key button

    After you do this, Save the table

  • 8/2/2019 Basics of MS Access

    20/41

    Switching ViewsTo switch views form the datasheet (spreadsheet view)

    and the design view, simply click the button in thetop-left hand corner of the Access program.

    Datasheet ViewDisplays the view, which allows you to enter raw data

    into your database table.

    Design ViewDisplays the view, which allows you to enter fields,

    data-types, and descriptions into your database table.

  • 8/2/2019 Basics of MS Access

    21/41

    Manipulating Data

    Adding a new row Simply drop down to a new line and enter the

    information

    Updating a record Simply select the record and field you want to

    update, and change its data with what you want Deleting a record

    Simply select the entire row and hit the DeleteKey on the keyboard

  • 8/2/2019 Basics of MS Access

    22/41

    Relationships After you've set up multiple tables in your Microsoft Access

    database, you need a way of telling Access how to bring thatinformation back together again. The first step in this processis to define relationships between your tables. After you'vedone that, you can create queries, forms, and reports to displayinformation from several tables at once.

    A relationship works by matching data in key fields - usually afield with the same name in both tables. In most cases, thesematching fields are the primary key from one table, whichprovides a unique identifier for each record, and a foreign key inthe other table. For example, teachers can be associated withthe students they're responsible for by creating a relationshipbetween the teacher's table and the student's table using the

    TeacherID fields.

  • 8/2/2019 Basics of MS Access

    23/41

    Drag the primary key of the Parent table (Teacherin this case), and drop it into the same field in the

    Child table (Student in this case.)

  • 8/2/2019 Basics of MS Access

    24/41

    Forms A form is nothing more than a graphical

    representation of a table. You can add, update, delete records in your table by

    using a form. NOTE: Although a form can be named different from

    a table, they both still manipulate the sameinformation and the same exact data. Hence, if youchange a record in a form, it will be changed in thetable also.

    A form is very good to use when you have numerousfields in a table. This way you can see all the fields in

    one screen, whereas if you were in the table view(datasheet) you would have to keep scrolling to getthe field you desire.

  • 8/2/2019 Basics of MS Access

    25/41

    Create a Form using the Wizard:The following steps are needed to create a basicform:

    Switch to the Database Window. Click on the Formsbutton under Objects on the left side of screen

    Double click on Create Form Using Wizard

  • 8/2/2019 Basics of MS Access

    26/41

    We want all of the fields from tbl_Sales to beincluded in this form, so first select tbl_Sales

    from the drop down box "Tables/Queries"

  • 8/2/2019 Basics of MS Access

    27/41

    The single right arrow will add one selected field ata time, but we want all the fields. The shortcut toadd every field from a given table or query is to

    click the double arrow button. Do that and clickNext.

  • 8/2/2019 Basics of MS Access

    28/41

    Choose a Columnar layout and press Next

    Choose any style and press Next (we chose"Sumi Painting")

    Change the form's title to frm_EmployeeEntry

    and click Finish

  • 8/2/2019 Basics of MS Access

    29/41

    Open the form

    Open up frm_EmployeeEntry

    At the bottom of the form is a set of arrows tonavigate through the records. To get to the endof the existing records and begin entering data

    you need to click the arrow with an asterisk(*).

  • 8/2/2019 Basics of MS Access

    30/41

    Clicking that button will bring you to the firstblank record, then enter all the data for thatrecord and click the right arrow to advance tothe next blank record. After all the newrecords have been entered, close the form andpat yourself on the back.

    When you enter data into this form it willautomatically add it to our existing tbl_Salesbecause we specified that table when wecreated our form. With this form the newemployee will be able to enter data into Bob's

    existing Access table.

  • 8/2/2019 Basics of MS Access

    31/41

    Reports A report is an effective way to present your data in a

    printed format. Because you have control over thesize and appearance of everything on a report, youcan display the information the way you want to see

    it.

  • 8/2/2019 Basics of MS Access

    32/41

    Create a Report using the Wizard Switch to the Database Window. Click on the Reports button under Objects on the left side of screen . Double click on Create Report Using Wizard On the next screen select the fields you want to view on your form.

    Most of the time you would select all of them. Click Next Select if you would like to group your files. Keep repeating this step for

    as many groupings as you would like. Click Next

    Select the layout and the paper orientation you desire Click Next Select the style you desire...HINT: if you plan on printing your report, I

    suggest you use a light background to save on printer toner and ink Click Next Give you report a name, and select Preview the Report

    Select Finish You should see your report. To adjust the design of your report, simply

    hit the design button (same as with the tables), and adjust your reportaccordingly

  • 8/2/2019 Basics of MS Access

    33/41

    Queries

    As tables grow in size they can have

    hundreds of thousands of records,which makes it impossible for theuser to pick out specific records

    from that table. Queries weredesigned to combat this problem.With a query you can apply a filter tothe table's data, so that you only getthe information that you want.

  • 8/2/2019 Basics of MS Access

    34/41

    Queries

    Choosing a Table to Query

    Before you can create a query you have to

    navigate to the Query Tab in your Accessdatabase. Select Queries from the Objects Pane.

  • 8/2/2019 Basics of MS Access

    35/41

    Queries

    Double-click "create Query inDesign view"

    Add the table tbl_Sales

  • 8/2/2019 Basics of MS Access

    36/41

    Your Query window should now have

    the tbl_Sales table added to it

  • 8/2/2019 Basics of MS Access

    37/41

    Drag and drop the Price field into the adjoining column andyou should have something like:

  • 8/2/2019 Basics of MS Access

    38/41

    Close the Query window and save your file queryas qry_ProdSales.

  • 8/2/2019 Basics of MS Access

    39/41

    Double-click your newly created query and weshould get the data

    Query Types

  • 8/2/2019 Basics of MS Access

    40/41

    Query Types

    Microsoft Access supports many types of queries. Here is a description ofthe major categories:

    Select QueriesRetrieve records or summaries (totals) across records. Also includes cross-tabulations.

    Make Table QueriesSimilar to Select queries but results are placed in a new table.

    Append Queries

    Similar to Select queries but results are added to an existing table.

    Update QueriesModify data in the records.

    Delete QueriesRecords are deleted from a table.

    Select queries are the most common queries and can be used for viewing and a datasource for forms, reports, controls, and other queries. The other queries create orchange data and are known collectively as Action queries.

    Criteria

  • 8/2/2019 Basics of MS Access

    41/41

    Criteria

    Text criteria please use ------

    For numbers use = , >, >=, = #2/2/1999# For an Order Date field, dates greater than and equal to2-Feb-99