![]() |
|
|
|
|
||
| Navigation Previous Next Homepage FAQ What's new Sitemap Topics Tutorials Others Contact |
Access - Macro commandsIntroduction IntroductionA macro allows to execute a series of instructions one after the other. Besides, you can "attach" a macro to a button on a form. The exercise that follows consists in creating a macro girl who contains a single instruction. Later, this macro short story(piece of news) will be attached to a button of a form. Create a macro
|
|
The window of creation of macro will appear.
Under the column Action is the list of the instructions that you can execute.
| As you see it, Access offers you several instructions.
To have more data about these
It's possible that it's a question the first time that the help is used inside Access.
Access will take a moment to generate the file of help.
The contents of the third box will change to show the columns in the word "action" contents in the file of help. This list includes also the actions of the macro. |
To continue the creation of the macro, it's necessary to enter the " arguments of the action " or the characteristics of this one. These arguments change according to the type of action. For the action BoîteMsg (message box):
Enter
the text following in the box message: " This is a test ".
Select
the Yes for the Bip option.
For
the type of window, select the Information type.
For
the title of the window, write the text "Test".
If you want to add another action, place the cursor below the last action and select it from the list of the actions.
To protect the macro:
From
the File menu, select the option, Save as / export.
Or
Press
the
button.
For
this exercise, enter the name "Test"
Press
the OK button.
The next part consists in attaching(fastening) the short story(piece of news) macro Test that has just been created in the previous part in a button of form. There are two ways to paste: paste to a new button or to an already existing button. This part will cover these two ways.
Return
to the main menu and click the Forms tab .
If you
already have a form, select it and press the Modify button.
Otherwise,
Press the New button. To accelerate the creation of a form, select one
InstantForm:Columns and the table of the employees.
When
the form is generated, enter the Design mode by pressing on the button.
From
the toolbar, select the command button.
Click on the form on the place where you want the command button to appear.
The assistant of command button offers several options. It contains several models of buttons to create quickly buttons the most used in various categories.
Among
the list of the categories, select the category "Miscellaneous".
Select
the option " Execute a macro " from the list of the actions.
Press
the Next button.
Among
the list of the macro available, select macro "Test".
Press the Next button.
Access the choice offers you to show of the text or an image on the top of the button. For this exercise, the text "Test" will be written on the button.
Click on the option Text:.
Write
the text "Test" in the box in the right-hand side of the option Text:.
Press the Next button.
It remains only to give a name to the button.
For
the exercise, write " Test of macro " in the first box of the window.
Press
the Finish button.
He can arrive that you change opinion and want to change macro or of option for an event or a button. This part of the page shows how to change you macro and the list of the possible events with Access.
Select
the Design mode for the form.
Place
the cursor over the button to be modified.
Press
the right mouse button.
From the
list of the possible options, select the Properties option.
Click
on the Event tab.
Access a possible list of the events shows you. You can attach a macro or a module to each of these events. It's so possible that Access executes a macro when you click a button or a field and a different event if you make a double-click on the same control.
Click
in the box in the right-hand side of the event " On click ".
Press
the button with a triangle pointing down at the end of the box.
From the
list of the macro and the modules, select macro Test.
Close
the window of the properties by pressing on the button.
When you go to press the button Test, one of both following windows will appear as the assistant of Access is shown in the screen or not.
Access offers you the opportunity to execute a macro-command at the opening of a database. This gives you the advantage to open with a macro to execute instructions. For example, you can open the database with a main menu form. You simply have to create a macro and giving it the Autoexec name. If you want to open a database without executing the autoexec macro at the opening, keep a finger on the Shift key at the time of opening the database.