O'Reilly logo

Expert Access™ 2007 Programming by Michael Tucker, Rob Cooper

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

Appendix A. Programming Tips and Tricks

This appendix contains some useful tips and tricks that you can use in your applications. Many of these code snippets are ones we have used over the years to help standardize our code or represent specific problems that we were trying to solve. Several of the techniques were born out of refactoring efforts to help make code more elegant. Refactoring is the process of making code more readable or simplified without changing the end result.

This appendix also covers such topics as running code dynamically and working with objects and dates. The appendix ends with some cool tools that you can add to your applications to make the process of writing code easier.

Dynamically Running Code

In many cases, you may want to run code dynamically — in other words, where the name of the routine that you want to execute is not known until runtime. For example, in Chapter 8 we used the Eval function to pass the name of a routine that was stored in a table for custom navigation in the application. VBA and the Access object model provides three mechanisms to do this: CallByName, Eval, and Application.Run.

CallByName

The CallByName function is defined by VBA and is used to invoke a property or method on an object instance. It can also be used to set a property value for an object instance. The parameters for the CallByName function are listed in the table that follows.

Parameter Name

Parameter Type

Description

Object

Object

An instance of an object whose property or method ...

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