Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Microsoft Access 2002 Tutorial 9 – Automating Tasks With Macros.

Similar presentations


Presentation on theme: "1 Microsoft Access 2002 Tutorial 9 – Automating Tasks With Macros."— Presentation transcript:

1 1 Microsoft Access 2002 Tutorial 9 – Automating Tasks With Macros

2 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access. Often users should not be given full access to Access  provide an interface that removes the user away from the Access interface. A Graphical User Interface (GUI) is a collection of windows, menus, dialog boxes and other graphical components used to communicate with a program. Often, the first view of a custom GUI is a switchboard.

3 3 What is a switchboard? A form that opens when you start the underlying database. Usually used to provide the user with a set of choices. Eliminates the need for users to interact directly with the database window. Can prevent users from making bad changes to form layout etc. The form you create for the switchboard is called a dialog box, which asks for user input in the way of a selection.

4 4 An example of a switchboard Notice that this switchboard provides command buttons to provide access to all the options available to the user. The figure below is an example of a switchboard form. The user would use this form to open the various objects in the database.

5 5 Macros Small program with a series of actions Actions are repeated whenever macro is invoked. An action is an instruction to Access to perform an operation, such as opening a form or displaying a query. Once the macro has been created, you can add actions to it by editing the macro in the Macro window.

6 6 Use the Macro window to add actions It is within the Macro window that you will supply the action name (chosen from a list), any comments you want to make, and the arguments for the action. Arguments are additional facts needed to run the action. Each type of action has its own set of arguments. A commonly used action is the Msgbox action, which will display a message to the user by way of a small form. Another commonly used action is the FindRecord action that will find the first record matching a set of criteria.

7 7 The Macro window This figure shows the Macro Window. In this window you can add macro actions and set the arguments for the macro actions. Notice that each action has a comment column. This column is used to document the macro. It is a good idea to write a comment about how this particular action will be used. Notice also the lower section of the window. This section contains the properties for the currently selected action.

8 8 Single-Step a macro When you run a macro, the series of actions are executing one after the other. Sometimes it is useful to test the macro one step at a time. This is called single stepping and causes the macro to perform one action, then waits for you to step to the next action. Can gain a clearer view of how the macro is working.

9 9 Create a macro Start with a blank macro and then add the actions to it. Drag an action from the database windows into the macro window. Each type of object has a default set of arguments.  For example, if you drag a table into the macro window, the default arguments are to open the table in datasheet view in edit mode. Drag as many objects as you want to the macro window. You can either accept the default arguments or you can edit them to meet your needs. Run the macro and observe the results of the macro.

10 10 Macro Groups A macro group is a macro that contains other macros. If you have several small related macros, you might consider grouping them together with other small macros in a macro group. Makes it easier to maintain a large collection of macros.

11 11 Add a macro to a macro group Each individual macro within the group will have a name assigned to it.  MacroGroupName.MacroName When you add a macro to a macro group, you add a new name to the Macro Name column. However, if you are simply adding an action to a macro within the group, you add only the new action in the Action column under the macro name.

12 12 A macro group with two macros In the figure below, you see an example of a Macro group window. Notice the new column added for the Macro name. Each macro in the group will contain a name in this column. Actions that will be taken within that macro will appear in the action column but without a name.

13 13 Use the Switchboard Manager to create a switchboard First, create all the macros you will need for the switchboard and then create the switchboard that will execute the macros. Use the Switchboard Manager to create the switchboard. The Switchboard Manager allows you to specify what buttons should be on the switchboard and identify the command to execute when each of the buttons is clicked.

14 14 Switchboard considerations Only one switchboard for a database; however, the switchboard can contain multiple pages. The main page of the switchboard will display when the switchboard opens. You can place buttons on the main page that will cause other pages in the switchboard to open.

15 15 The completed switchboard This final figure shows the complete switchboard, which has buttons for each of the objects with which the user can interact.


Download ppt "1 Microsoft Access 2002 Tutorial 9 – Automating Tasks With Macros."

Similar presentations


Ads by Google