I just came up with a really tidy little solution to the VB/VBA circular
reference issue. It only works with Access 2000 or newer, but that's about
the only down-side.
The issue...
You need an object model that includes a container object, and the object in
the container need to interact with the container itself. The problem is
that, to access the container, each item needs a reference to the container,
and that constitutes a circular reference since the container also contains an
array or a collection that contains a reference to the contained object.
Unless extreme caution is used, this structure can hold itself in memory even
though all externalr references to it have gone out of scope, and memory will
gradually be swallowed up each time a new one is created.
As of Access 2000, there is a tool that seems to handle this which is the
ability to create and raise custom events to communicate with a referring
object, but this only works for single references, not arrays or collections.
The solution...
Create a generic proxy class that can be referenced by both a container and a
contained item that can be asked to raise an event to the container to ask for
a temporary reference to the container for use within a single function call.
clsContainerAccessor
==========
Option Explicit
Option Compare Database
Event RequestReference(ByRef objReference As Object)
Public Property Get Reference() As Object
Dim objReference As Object
RaiseEvent RequestReference(objReference)
Set Reference = objReference
End Property
==========
In the contianer, add code like this...
==========
Private WithEvents mobjAccessor As clsContainerAccessor
Private Sub mobjAccessor_RequestReference(objReference As Object)
Set objReference = Me
End Sub
Private Sub Class_Initialize()
Set mobjAccessor = New clsContainerAccessor
End Sub
==========
When the container creates a new contained item, it can supply the item with a
reference to mobjAccessor, and the item can obtain a temporary reference to
the container by accessing the Reference property of that object as needed.