Ms Access 简明教程

MS Access - Objects

MS Access 使用“对象”来帮助用户列出和组织信息,以及准备专门设计的报表。当你创建一个数据库时,Access 为你提供了表、查询、表单、报表、宏和模块。Access 中的数据库由许多对象组成,但以下是最主要的几个对象 -

MS Access uses “objects" to help the user list and organize information, as well as prepare specially designed reports. When you create a database, Access offers you Tables, Queries, Forms, Reports, Macros, and Modules. Databases in Access are composed of many objects but the following are the major objects −

  1. Tables

  2. Queries

  3. Forms

  4. Reports

这些对象共同允许你输入、存储、分析和汇编你的数据。以下是 Access 数据库中主要对象的摘要;

Together, these objects allow you to enter, store, analyze, and compile your data. Here is a summary of the major objects in an Access database;

Table

表是用于定义和存储数据的对象。当你创建一个新表时,Access 会要求你定义字段,也称为列标题。

Table is an object that is used to define and store data. When you create a new table, Access asks you to define fields which is also known as column headings.

  1. Each field must have a unique name, and data type.

  2. Tables contain fields or columns that store different kinds of data, such as a name or an address, and records or rows that collect all the information about a particular instance of the subject, such as all the information about a customer or employee etc.

  3. You can define a primary key, one or more fields that have a unique value for each record, and one or more indexes on each table to help retrieve your data more quickly.

Query

提供来自一个或多个表的数据的自定义视图的对象。查询是一种从小表或大表搜索和编译数据的方式。

An object that provides a custom view of data from one or more tables. Queries are a way of searching for and compiling data from one or more tables.

  1. Running a query is like asking a detailed question of your database.

  2. When you build a query in Access, you are defining specific search conditions to find exactly the data you want.

  3. In Access, you can use the graphical query by example facility or you can write Structured Query Language (SQL) statements to create your queries.

  4. You can define queries to Select, Update, Insert, or Delete data.

  5. You can also define queries that create new tables from data in one or more existing tables.

Form

表单是桌面数据库中的一个对象,主要用于数据输入或显示,或用于控制应用程序执行。你使用表单自定义应用程序从查询或表中提取的数据的演示文稿。

Form is an object in a desktop database designed primarily for data input or display or for control of application execution. You use forms to customize the presentation of data that your application extracts from queries or tables.

  1. Forms are used for entering, modifying, and viewing records.

  2. The reason forms are used so often is that they are an easy way to guide people toward entering data correctly.

  3. When you enter information into a form in Access, the data goes exactly where the database designer wants it to go in one or more related tables.

Report

报告是桌面数据库中的对象,用于对所选数据进行格式化、计算、打印和总结。

Report is an object in desktop databases designed for formatting, calculating, printing, and summarizing selected data.

  1. You can view a report on your screen before you print it.

  2. If forms are for input purposes, then reports are for output.

  3. Anything you plan to print deserves a report, whether it is a list of names and addresses, a financial summary for a period, or a set of mailing labels.

  4. Reports are useful because they allow you to present components of your database in an easy-to-read format.

  5. You can even customize a report’s appearance to make it visually appealing.

  6. Access offers you the ability to create a report from any table or query.

Other MS Access Objects

现在让我们来看一下其他 MS Access 对象。

Let us now take a look at other MS Access objects.

Macro

此对象是一个或多个操作的结构化定义,您希望 Access 在响应定义的事件时执行这些操作。Access Macro 是执行某些工作的脚本。例如,要创建一个打开报告的按钮,您可以使用一个会触发 OpenReport 操作的宏。

This object is a structured definition of one or more actions that you want Access to perform in response to a defined event. An Access Macro is a script for doing some job. For example, to create a button which opens a report, you could use a macro which will fire OpenReport action.

  1. You can include simple conditions in macros to specify when one or more actions in the macro should be performed or skipped.

  2. You can use macros to open and execute queries, to open tables, or to print or view reports.

  3. You can also run other macros or Visual Basic procedures from within a macro.

  4. Data macros can be attached directly to table events such as inserting new records, editing existing records, or deleting records.

  5. Data macros in web apps can also be stand-alone objects that can be called from other data macros or macro objects.

Module

模块是桌面数据库中的一个对象,它包含您使用 Visual Basic 编码的自定义过程。模块提供了更加离散的操作流程,并允许您捕获错误。

Module is an object in desktop databases containing custom procedures that you code using Visual Basic. Modules provide a more discrete flow of actions and allow you to trap errors.

  1. Everything that can be done in a macro can also be done in a module, but you don’t get the macro interface that prompts you what is needed for each action.

  2. Modules are far more powerful, and are essential if you plan to write code for a multi-user environment, because macros cannot include error handling.

  3. Modules can be standalone objects containing functions that can be called from anywhere in your application, or they can be directly associated with a form or a report to respond to events on the associated form or report.