AddressOf is not supported in Access/Office 97 (or any
previous version). There's a good chance though, that it will be supported in VBA 6,
or Office 2000.
However, Ken Getz and Michael Kaplan, in Microsoft Office and VBA Developer Magazine,
have published an undocumented method of getting the address (pointer) to a procedure in
VBA environment.
The AddressOf code is available at Trigeminal's
website).
Try to get that particular issue (May, 1998) of the magazine to
read the accompanying detailed article as well since there are a bunch of issues that you
should be aware of.
AddressOf, now a standard operator in VB 5, can be used to pass the
address of a user defined function to an API function. This allows us to use several other
APIs which require a callback function. This in turn allows us to subclass an Access form
for additional functionality. (Subclassing is a technique that enables us to intercept
Windows messages being sent to a form or control.)
Warnings:
- AddressOf is COMPLETELY UNSUPPORTED by Microsoft in Office 97
environment. Use it at your own risk!!
- Entering debug mode is not recommended as it is likely to
cause problems (GPFs etc.).
- Make sure you backup your work and save before running any
such code. Using this technique adds another level of
instability since there are so many different ways to set up
things wrong. Once you get it to work properly,
everything should be ok.
- Make sure you enter a On Error Resume Next at the top of
any callback function. This is done to ensure that any errors
within a callback function are not propagated back to its
caller.
- Be careful of ByVal or ByRef when passing arguments to the function.
If you don't get this right, nothing's going to work.
|