CDaoFieldInfo Structure

The CDaoFieldInfo structure has the following form:

struct CDaoFieldInfo
{
   CString m_strName;           // Primary
   short m_nType;               // Primary
   long m_lSize;                // Primary
   long m_lAttributes;          // Primary
   short m_nOrdinalPosition;    // Secondary
   BOOL m_bRequired;            // Secondary
   BOOL m_bAllowZeroLength;     // Secondary
   long m_lCollatingOrder;      // Secondary
   CString m_strForeignName;    // Secondary
   CString m_strSourceField;    // Secondary
   CString m_strSourceTable;    // Secondary
   CString m_strValidationRule; // All
   CString m_strValidationText; // All
   CString m_strDefaultValue;   // All
};

The CDaoFieldInfo structure contains information about a field object defined for data access objects (DAO). The references to Primary, Secondary, and All above indicate how the information is returned by the GetFieldInfo member function in classes CDaoTableDef, CDaoQueryDef, and CDaoRecordset.

Field objects are not represented by an MFC class. Instead, the DAO objects underlying MFC objects of the following classes contain collections of field objects: CDaoTableDef, CDaoRecordset, and CDaoQueryDef. These classes supply member functions to access some individual items of field information, or you can access them all at once with a CDaoFieldInfo object by calling the GetFieldInfo member function of the containing object.

Besides its use for examining object properties, you can also use CDaoFieldInfo to construct an input parameter for creating new fields in a tabledef. Simpler options are available for this task, but if you want finer control, you can use the version of CDaoTableDef::CreateField that takes a CDaoFieldInfo parameter.

Members

m_strName

Uniquely names the field object. For details, see the topic "Name Property" in DAO Help.

m_nType

A value that indicates the data type of the field. For details, see the topic "Type Property" in DAO Help. The value of this property can be one of the following:

m_lSize

A value that indicates the maximum size, in bytes, of a DAO field object that contains text or the fixed size of a field object that contains text or numeric values. For details, see the topic "Size Property" in DAO Help. Sizes can be one of the following values:

Type Size (Bytes) Description
dbBoolean 1 byte Yes/No (same as True/False)
dbByte 1 Byte
dbInteger 2 Integer
dbLong 4 Long
dbCurrency 8 Currency (COleCurrency)
dbSingle 4 Single
dbDouble 8 Double
dbDate 8 Date/Time (COleDateTime)
dbText 1 - 255 Text (CString)
dbLongBinary 0 Long Binary (OLE Object; CByteArray; use instead of CLongBinary)
dbMemo 0 Memo (CString)
dbGUID 16 A Globally Unique Identifier/Universally Unique Identifier used with remote procedure calls.

m_lAttributes

Specifies characteristics of a field object contained by a tabledef, recordset, querydef, or index object. The value returned can be a sum of these constants, created with the C++ bitwise-OR (|) operator:

m_nOrdinalPosition

A value that specifies the numeric order in which you want a field represented by a DAO field object to be displayed relative to other fields. You can set this property with CDaoTableDef::CreateField. For details, see the topic "OrdinalPosition Property" in DAO Help.

m_bRequired

Indicates whether a DAO field object requires a non-Null value. If this property is TRUE, the field does not allow a Null value. If Required is set to FALSE, the field can contain Null values as well as values that meet the conditions specified by the AllowZeroLength and ValidationRule property settings. For details, see the topic "Required Property" in DAO Help. You can set this property for a tabledef with CDaoTableDef::CreateField.

m_bAllowZeroLength

Indicates whether an empty string ("") is a valid value of a DAO field object with a Text or Memo data type. If this property is TRUE, an empty string is a valid value. You can set this property to FALSE to ensure that you cannot use an empty string to set the value of a field. For details, see the topic "AllowZeroLength Property" in DAO Help. You can set this property for a tabledef with CDaoTableDef::CreateField.

m_lCollatingOrder

Specifies the sequence of the sort order in text for string comparison or sorting. For details, see the topic "Customizing Windows Registry Settings for Data Access" in DAO Help. For a list of the possible values returned, see the m_lCollatingOrder member of the CDaoDatabaseInfo structure. You can set this property for a tabledef with CDaoTableDef::CreateField.

m_strForeignName

A value that, in a relation, specifies the name of the DAO field object in a foreign table that corresponds to a field in a primary table. For details, see the topic "ForeignName Property" in DAO Help.

m_strSourceField

Indicates the name of the field that is the original source of the data for a DAO field object contained by a tabledef, recordset, or querydef object. This property indicates the original field name associated with a field object. For example, you could use this property to determine the original source of the data in a query field whose name is unrelated to the name of the field in the underlying table. For details, see the topic "SourceField, SourceTable Properties" in DAO Help. You can set this property for a tabledef with CDaoTableDef::CreateField.

m_strSourceTable

Indicates the name of the table that is the original source of the data for a DAO field object contained by a tabledef, recordset, or querydef object. This property indicates the original table name associated with a field object. For example, you could use this property to determine the original source of the data in a query field whose name is unrelated to the name of the field in the underlying table. For details, see the topic "SourceField, SourceTable Properties" in DAO Help. You can set this property for a tabledef with CDaoTableDef::CreateField.

m_strValidationRule

A value that validates the data in a field as it is changed or added to a table. For details, see the topic "ValidationRule Property" in DAO Help. You can set this property for a tabledef with CDaoTableDef::CreateField.

For related information about tabledefs, see the m_strValidationRule member of the CDaoTableDefInfo structure.

m_strValidationText

A value that specifies the text of the message that your application displays if the value of a DAO field object does not satisfy the validation rule specified by the ValidationRule property setting. For details, see the topic "ValidationText Property" in DAO Help. You can set this property for a tabledef with CDaoTableDef::CreateField.

m_strDefaultValue

The default value of a DAO field object. When a new record is created, the DefaultValue property setting is automatically entered as the value for the field. For details, see the topic "DefaultValue Property" in DAO Help. You can set this property for a tabledef with CDaoTableDef::CreateField.

Comments

Information retrieved by the GetFieldInfo member function (of the class that contains the field) is stored in a CDaoFieldInfo structure. Call the GetFieldInfo member function of the containing object in whose Fields collection the field object is stored. CDaoFieldInfo also defines a Dump member function in debug builds. You can use Dump to dump the contents of a CDaoFieldInfo object.

For information on using this and other MFC DAO Info structures, see the article DAO Collections: Obtaining Information About DAO Objects in Visual C++ Programmer's Guide.

See Also   CDaoTableDef::GetFieldInfo, CDaoRecordset::GetFieldInfo, CDaoQueryDef::GetFieldInfo