Beruflich Dokumente
Kultur Dokumente
Ethiopian TVET-System
Level II
LEARNING GUIDE # 1
Macros
Macros in Access can be thought of as a simplified programming language which you can use to add
functionality to your database.
For example, you can attach a macro to a command button on a form so that the macro runs whenever the
button is clicked.
Macros contain actions that perform tasks, such as opening a report, running a query, or closing the database.
Most database operations that you do manually can be automated by using macros, so they can be great time-
saving devices.
A macro is essentially a list of actions that you apply to objects to respond to events.
Each action carries out one task.
You create your actions in the order you want them to execute.
In addition, you specify the arguments of the actions, giving the program additional information as needed.
You can set conditions for each action in a macro to determine whether it runs or not.
Run a macro by applying it to the event property of an object.
Once the specified event occurs the macro will run by running the all the specified actions.
Actions that have conditions applied to them may or may not run depending on whether or not they passed the
conditional tests.
Once you've created your macros you'll see them listed in the Macros tab in the Database window.
This way you can attach any macro to any event property in your database.
Macro Creation
Create and manage macros from the "Macros" section in the Access database window.
Select an action from the "Action" drop-down menu.
Choose your action arguments at the bottom of the window.
This includes choosing the object the action applies to, the object name, sizes, positions, application
name, and any other arguments that apply to your selected action.
The "Action" column is the only portion of the macro window that must be filled out. You must have at
least one action per macro.
Create a new action by going to the next row.
Remember that all actions in the macro will run each time the macro is run.
TTLM Development Manual Date: 05-2011 Page 2 of 9
3rd Revision Author: ADDIS ABABA TEGBARE-ID
Ethiopian TVET System
Training, Teaching and Learning Material
Actions
Comments
Running Macros
Modules
Modules, like macros, are objects you can use to add functionality to your database.
Whereas you create macros in Access by choosing from a list of macro actions, you write modules in
the Visual Basic for Applications (VBA) programming language.
A module is a collection of declarations, statements, and procedures that are stored together as a unit.
A module can be either a class module or a standard module.
Class modules are attached to forms or reports, and usually contain procedures that are specific to the
form or report they're attached to.
Standard modules contain general procedures that aren't associated with any other object.
Standard modules are listed under Modules in the Navigation Pane, whereas class modules are not.
Now that you know how to put together a program, you are ready to give it a try.
To create a VBA procedure, you follow many of the same steps you follow when you created macros.
The general steps in VBA programming are as follows:
You create VBA programming code by using the VBA Editor, which is described in the following
section.
You create VBA programs using the VBA Editor. To start the VBA Editor,
First click your mouse on the Modules button in the Database window.
Then, click your mouse on the New button. Access, in turn, displays the VBA Editor, as shown in figure
Notice
Note: If a window is not displayed within the VBA Editor, you can display it by choosing one of the
options from the View menu. For instance, if you want to display the Project window, choose
Project Explorer from the View menu.
A data access page is a special type of Web page designed for viewing and working with data from the
Internet or an intranet— data that is stored in a Microsoft Access database or a Microsoft SQL Server
database.
The data access page may also include data from other sources, such as Microsoft Excel.
Using a data access page is similar to using a form: You can view, enter, edit, and delete data in a
database.
However, you can also use a page outside a Microsoft Access database, so users can update or view
data over the Internet or an intranet.
The body - The body is the basic design surface of a data access page.
On a page that supports data entry, you can use it to display informational text, controls bound
to data, and sections.
Sections - You use sections to display text, data from a database, and toolbars.
Two types of sections are typically used on pages that support data entry:
Group header and Record navigation sections.
A page can also have footer and caption sections.
Group header and footer: Used to display data and calculate values.
Record navigation: Used to display the record navigation control for the group level.
o A record navigation section for a group appears after the group header section.
o You can't place bound controls in a record navigation section.
Caption: Used to display captions for text boxes and other controls. It appears immediately
before the group header.
o You can't place bound controls in a caption section.
Each group level in a data access page has a record source. The name of the record source is displayed
on the section bar for each section used for a group level.
Data analysis: This type of data access page may include a PivotTable list, similar to a Microsoft
Excel PivotTable report, that lets you reorganize the data to analyze it in different ways.
The page might contain a chart that you can use to analyze trends, detect patterns, and compare
data in your database. Or it might contain a spreadsheet, in which you can enter and edit data and
use formulas to calculate as you do in Excel.
Note :- To view and work with the data access page on the Internet or an intranet, users need
Microsoft Internet Explorer 5.01 with Service Pack 2 (SP2) or later.
You can also work with a data access page in Page view in Access.
Data access pages can supplement the forms and reports that you use in your database application.
When deciding whether to design a data access page, form, or report, consider the tasks that you want
to perform.