Access tutorial

Previous page Previous     TOC Contents     Next pageNext


Lesson 11 for

Writing macros







For more information and special deals related to any of the issues on this page, place your cursor over the double-underlined links.
All information supplied by Kontera.com.




We're back!


If you've been following this tutorial over the past few months you may have noticed that there haven't been any updates to the lessons in several weeks. I'm sorry about that.

What happened was that my version of MS-Office crashed. When I finally got a new version I had Windows Installer problems. Then I had to go through DLHell like so many before me! Well, it looks like we're finally back on track. You may notice slight differences in the pictures of the interface since I'm now using Access XP instead of Access 2000. However, everything still works the same.

And a final note on that subject: Thank you to the good folks at Google Groups. If you haven't discovered that little gem you're really missing-out on some valuable tools.


Macros



When you want to control the flow of activities in the application there are several ways you can go. We'll look at a couple of them.

First, if you don't want to use the Menu Manager discussed in the previous lesson, you can create your own menu using a simple form, as in the example below.







If you only have a form with buttons, nothing much will happen. You have to tell the application what to do when a button is clicked. That's what macros are for.












It's important to save the macro and name it. Give it the same name as the form it's on. That will simplify your life later. If you use macros you'll probably end-up with dozens in the application. Trust me: if you use names like macro1 and macro2 and so on, you'll tear your hair out later in trying to find what each one does. So, name the macro the same as the form it's on and name the actions inside the macro the same as the buttons.





















Macros can also be used to open a form from another form.

For example, if you have to change the customer's address while the customer is renting a movie, you don't do the change in the Invoice form. You call the Customers form from the Invoice form. The trick is to make sure that the Customers form that opens is the one for the customer who is on the invoice.

We could create a macro for that.

However, it's more easily done by using the Wizard. Make sure the Wizard is activated in the Toolbox (the magic wand) and it will be called automatically when you create the button.





















Finally, you should add navigation buttons to all forms.

You may have noticed that the navigation bar at the bottom of every form, although it is functional, it is small and hard to work. Adding navigation buttons makes it easier for the user.

Every form should have the standard buttons: First, Previous, Next, Last, New record, Close form