61 Slices
Medium 9781565924352

Properties Collection Properties

Helen Feddema O'Reilly Media PDF

Item

The

The

The

The

The

The

343

Properties property of the

Properties property of the

CreateProperty method of

Properties property of the

Properties property of the

Properties property of the

Recordset object

Relation object the TableDef object

TableDef object

User object

Workspace object

Properties Collection Properties

Count

Data Type

Integer

Description

The number of properties in a Properties collection. In previous versions of

Access, Count was useful for setting up loops to process all objects in a collection; however, the For Each...Next loop is a more efficient way of iterating through the members of a collection (see the Append section for an example of using For Each...Next to process all members of the Properties collection).

Item

Properties.Item(Index)

Argument

Data Type

Description

Index

Integer

Represents the ordinal position of the property in the Properties collection or a string containing the name of the property to be retrieved from the Properties collection

Data Type

Property object

Description

Retrieves a particular Property object from the Properties collection, using the index number or the property name. Item is the default property, so it may be omitted; the following two code fragments are equivalent:

See All Chapters
Medium 9781565924352

Index Object Methods

Helen Feddema O'Reilly Media PDF

CreateField

339

If you have a choice of setting the Required property for a field or an index, set it for the field, as a field will be checked before an index.

Unique

Data Type

Boolean

Description

For Jet workspaces only, indicates whether an index is a unique (key) index for a table. This property is read/write until the index is appended to a collection, and read-only after it is appended. A unique index arranges all records in a table in a unique, predefined order. If the index has only one field, each record must have a unique value in that field; if it is a multifield index, each combination of the index fields must be unique.

Index Object Methods

CreateField

Set field = index.CreateField(name, type, size)

Argument

Data Type

Description

field

Field object

The field you are creating

index

Index object

The index for which you are creating the new field

name

String

(Optional) The name of the new field; it may be up to 64 characters in length

type

Integer

Ignored when creating index fields

size

Integer

Ignored when creating index fields

See All Chapters
Medium 9781565924352

Property Object Properties

Helen Feddema O'Reilly Media PDF

346

Chapter 16: Properties Collection and Property Object

Property Object Properties

Inherited

Data Type

Boolean

Description

Indicates whether a property is inherited from an underlying object. For built-in properties, Inherited is always False; for user-defined properties, it can be True.

For example, if a user-defined property is created for a TableDef object, and a recordset is created based on the TableDef, the property will be inherited by the

Recordset object.

This property appears to be buggy. Running the following code reveals that the new user-defined property that the recordset inherited from the TableDef actually has its inherited property set to

False; it should be True.

VBA Code

This code illustrates creating a user-defined property for a table, then creating a recordset based on the table, and listing its properties, noting whether they are inherited:

Private Sub cmdInherited_Click()

Dim

Dim

Dim

Dim

Dim

dbs As tdf As rst As prp As prpNew

Database

TableDef

Recordset

Property

As Property

Set dbs = OpenDatabase("D:\Documents\Northwind.mdb")

See All Chapters
Medium 9781565924352

Parameters Collection Properties

Helen Feddema O'Reilly Media PDF

322

Chapter 14: Parameters Collection and Parameter Object

Parameters Collection Properties

Count

Data Type

Integer

Description

Gives the number of Parameter objects in a Parameters collection. In previous versions of Access, Count was useful for setting up loops to process all objects in a collection; however, the For Each...Next loop is a more efficient way of iterating through the members of a collection.

Item

Parameters.Item(Index)

Argument

Data Type

Description

Index

Integer

The ordinal position of the Parameter object in the Parameters collection, or a string containing the name of the Parameter object to be retrieved from the collection

Data Type

Parameter object

Description

A hidden property in the Object Browser, the Item property retrieves a particular

Parameter object from the Parameters collection. A Parameter object can be retrieved either based on its ordinal position in the collection or based on its name. Since Parameters is a zero-based collection, the following code fragment returns the first Parameter object:

See All Chapters
Medium 9781565924352

Errors Collection Methods

Helen Feddema O'Reilly Media PDF

Description

45

Errors Collection Methods

Refresh

Errors.Refresh

Updates the objects in the Errors collection so that the Number property of the last member of the Errors collection matches the value of the VBA Err object. This is necessary if you are going to use a Select Case statement to identify the particular DAO error or errors that occurred, for example, in an error-handling construct.

Error Object Properties

Description

Type

String

Description

Describes the error. You can use this string in standard error-handling code when you don’t want (or need) to write your own custom error messages, as in the following code sample.

VBA Code

Figure 3-2 shows the dialog box generated by the code in this example, which lists all of the Error object’s properties:

Public Function ErrorProps()

On Error GoTo ErrorPropsError

Dim dbs As Database

Dim strError As String

Dim err As Error

'Try to set dbs to a nonexistent database to

'generate a DAO error.

Set dbs = OpenDatabase("None.mdb")

ErrorPropsExit:

Exit Function

ErrorPropsError:

See All Chapters

See All Slices