O'Reilly logo

Access 2003 VBA Programmer's Reference by Armen Stein, Graham Seach, Teresa Hennig, Patricia Cardoza

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10.3. Event Property and Procedure Examples

The remainder of this chapter will apply all of the information covered in the previous sections to get you started on the automation of Access Forms. The examples are in no particular order and do not rely on each other for reader comprehension. In case an example is associated to another, it will be noted. This allows for the reading of only the property examples that are pertinent to you.

10.3.1. Form_Open(): Passing the OpenArgs Parameter

The Form Open event property triggers whenever a form is opened. Each form is only opened once, so this event should theoretically trigger only one time. ("Theoretically" is used here because there are cases when events should fire only once, but they end up firing more than once. Don't take this warning too seriously, but if you suddenly have trouble with a procedure, trace it and see if this is happening.)

In the OpenForm method of the DoCmd object, there is a parameter called OpenArgs that will allow you to pass a string to the called Form. There is no structure to the parameter value, other than it needs to be a string.

For example, the following will open the form called Orders and pass it the string value.

Docmd.OpenForm "Orders", OpenArgs:="CallingProc |  MainMenu"

When the form opens, you can examine the OpenArgs property using the Me object. See the earlier section You Talking to Me? for more information. The following example will examine the OpenArgs property of the form, and react to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required