Name Property

See Also    Example    Applies To

Sets or returns a user-defined name for a DAO object. For an object not appended to a collection, this property is read/write.

Syntax

VOIDSetName(LPCTSTR pstr );

StringGetName(VOID);

Parameters

Type Argument Description
LPCTSTR pstr A pointer to a string that contains the name of the object.

Remarks

The name must start with a letter. The maximum number of characters depends on the type of object Name applies to, as shown in Remarks. It can include numbers and underscore characters ( _ ) but can't include punctuation or spaces.

CdbTableDef, CdbQueryDef, CdbField, CdbIndex, CdbUser, and CdbGroup objects can't share the same name with any object in the same collection.

The Name property of a CdbRecordset object opened by using an SQL statement is the first 256 characters of the SQL statement.

Note For many of the DAO objects, the Name property reflects the name as known to the CdbDatabase object, as in the name of a CdbTableDef, CdbField, or CdbQueryDef object. There is no direct link between the name of the DAO object and the object variable used to reference it.

The read/write usage of the Name property depends on the type of object it applies to, and whether or not the object has been appended to a collection. In an ODBCDirect workspace, the Name property of an appended object is always read-only. The following table indicates whether the Name property in a Microsoft Jet workspace is read/write or read-only for an object that is appended to a collection (unless otherwise noted), and also indicates its maximum length in cases where it is read/write.

Object Usage Maximum length
CdbContainer Read-only  
CdbConnection Read-only
CdbDatabase Read-only
CdbDocument Read-only
CdbField  
Unappended Read/write 64
Appended to CdbIndex Read-only  
Appended to CdbQueryDef Read-only
Appended to CdbRecordset Read-only
Appended to CdbTableDef (native) Read/write 64
Appended to CdbTableDef (linked) Read-only  
Appended to CdbRelation Read-only
CdbGroup  
Unappended Read/write 20
Appended Read-only  
CdbIndex  
Unappended Read/write 64
Appended Read-only  
CdbParameter Read-only
CdbProperty  
Unappended Read/write 64
Appended Read-only  
Built-in Read-only
CdbQueryDef  
Unappended Read/write 64
Temporary Read-only  
Appended Read/write 64
CdbRecordset Read-only  
CdbRelation  
Unappended Read/write 64
Appended Read-only  
CdbTableDef Read/write 64
CdbUser    
Unappended Read/write 20
Appended Read-only  
CdbWorkspace  
Unappended Read/write 20
Appended Read-only