Sie sind auf Seite 1von 5

MS Access Databases Advance/Other Functions Compiled by Ronelle Klinck for the CAT User Group Conference 2010 Scenario:

The database file referred throughout the booklet is labelled Laylas Foods.mdb. Layla makes delicious foods e.g. Sweet and savoury sauces, relishes, spreads, and seasonings. She has 9 employees which assist in sales and distributing the foods around the world. Laylas customers are based in countries such as the UK, Canada, Germany, Brazil etc. 1. INSERTING THE TIME DATA WAS CAPTURED Purpose: Allows the date and time to automatically be entered every time new data is entered. Example: If we want to keep track of every time a new employee is entered into the database. Refer to the screenshot below in the Employees table. A new field has been entered i.e. Employees commencement, Date/Time data type and Now() function added in the Default value.

In the datasheet view the date is automatically inserted every time a new record is entered.

2. SWITCHBOARD Purpose: Database designers/administrators can deactivate all/certain menus to restrict users rights. Some users e.g. data capturers may be restricted to add new records to a form (i.e. front-end) but they will not be able to change anything e.g. data types, input masks etc in back-end of a database. To view an example open the file Switchboard.mdb Heres how: Create a form OR Open the file Laylas Foods.mdb

In Office 2003 Select Tools, Startup - In Office 2007, Click the Office button, Select Windows Options Label the Switchboard e.g. Capture Orders Deactivate all the menus (see screenshot below) Select the form you want to display as the switchboard e.g. Orders Select OK Close the database file and reopen the file (All menus should be hidden and you should only be able to view the Orders form)

To reactivate all menus hold down the Shift key while opening the file

3. ACTION QUERIES Purpose: Action queries work like macros i.e. to add/modify/perform an action etc. Once an action query is run/activated the changes cannot be undone. Action queries can be designed to delete several records in a table, update all records in a table etc. Make use of the following icon to access the Action query options in Query, Design View:

a. UPDATE QUERIES Purpose: Update queries modify the data stored in a table. In one operation, all the records can be changed at the same time, or only records that meet specific criteria e.g. all orders made after Jan 2010. We will use the Orders table for this example. We will add 5% to the Freight cost as follows:

b. APPEND QUERY Purpose: Append queries add specific rows/records to a table. We will use the Orders and Shipping details tables to create an Append Query. We can insert one row or various rows at the same time, normally getting the data from another table, and so an append query has a source (the table or tables where it gets the data from) and a destiny (the table where we will insert the data). The function is similar to a make-table query as we define a selection query which permits us to obtain the data to save, and what does vary is that now we have to indicate into which column we want to save every value. Heres how: The Order table has various other records for Ship Postal codes and Ship countries which does not appear in the Ship details table. Create an Append query to add the other records to the Ship details table. Open a new query in design view Insert/Add the fields Ship codes and Ship countries from the Order table Run the query and you should notice that the records are duplicated To remove the duplication, go back to design view Open the Properties menu (see icon) Under Unique values, select Yes and close the Properties menu (View the query in datasheet & notice that there are no duplicate values any longer) Click on the Append query option, select the table you want to Append e.g. Shipping details Ensure that the fields and options for Append To are setup as in the screenshot below. Run and save the query to update the records in the Shipping details table (notice that when you open the Shipping details table, all the other records for ShipPostalCodes and ShipCountries appear)

c. DELETE QUERY Purpose: To delete records from a table and from other tables in the relational database. Example: In the Categories table from Laylas Foods database we want to delete the Seafood category. Heres how: Create a new query using the Categories table Select the Delete query option Ensure that the query is setup as indicated in the screenshot below: Run and save the query (notice that when you open the Category table the Seafood record is deleted)

Indicates the field to locate the record and the criteria to search

Indicates the table in which to find the record you want to delete

4. SUMMARY QUERIES Note that a Summary query is not an action query! Purpose: Used instead of creating a report to find the sum/average etc of a group of records. Example: All countries have more than one entry in the Orders table for Freight costs. We will use the Orders tables and find the total Freight costs for all countries and group them by the Shipping country. Heres how: Open a new query using the Orders table Add/Insert the fields Shipping country and Freight Select the icon AutoSum Setup the query further by selecting the options as indicated in the screenshot below Run and save the query (notice that the query lists all the countries total value for freight costs)

5. SPLITTING A DATABASE Purpose: Splitting a database can be done to temporarily delete relationships between tables and give certain users access to one or two tables but not all the tables as in this workbook example to split the database into a front and back end Heres how: Notice that when you open the Laylas Foods database there are various one to many relationships that exist between tables. Select Tools, Database Utilities and Database Splitter Select Split Database Save the Back end as another filename, select Split and OK Notice that the relationships between tables have been deleted and each table is a separate entity in the database

References: For a step by step guide on how to create Action queries refer to: http://www.teacherclick.com

Das könnte Ihnen auch gefallen