first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

Book: Access 97 Power Programming; Chapter 3 Highlights (1/3): "Working with Application Collections And Data Access Objects"

Declaring a Collection Variable

A user-defined collection is a new instance of a collection object. Its "instancing" requires the New keyword. The abbreviated way of declaring a new collection object has the form:

Dim <my collection object variable> as New Collection

e.g.

Dim colExample as New Collection

This form is useful at procedure level in the code module. However the non-abbreviated way of delcaring any new object uses two statements instead of one. The first statement is in the declarations section of the module:

Public p_colExample as Collection

This object variable is now avaible for use and re-use throughout the application. At the procedure level, we can Set this variable equal to a New Collection:

Set p_colExample = New Collection

Although this appears redundant, it is now possible to quickly destroy the contents of a collection with the code:

Set p_colExample = Nothing

Now this collection object variable can be reused in other modules.

Index Numbers in Collections

Intrinsic Access collections are 0-based while user-defined collection indices are 1-based.

For a detailed discussion of how collections differ from arrays, please see "Creating Custom Collections" (pg. 67) and "Comparing Custom Collections to Arrays" (pg. 70).

The Access Object Model

The Access Object Model is a containment hierarchy that begins with the Application object. Please see "Accessing the Access Object Model" (pg. 73). Here are some noted methods of the Application object:

Application. Echo Application.GetOption Application.SetOption

The Screen Object

The Screen object is of the Application object. Here are some noted properties of the Screen object:

Screen. ActiveForm Screen.ActiveReport Screen.ActiveControl Screen.PreviousControl

Note that there is no need to specify the Application keyword in code within Access.

mod date: 1998-10-01T20:42:08.000Z