DAO Record Field Exchange: Using the DFX Functions

OverviewHow Do IFAQSampleODBC Driver List

This article explains how to use the DFX function calls that make up the body of your DoFieldExchange override.

****Note   ****This article is about the DAO version of record field exchange. If you are using the MFC ODBC classes rather than the MFC DAO classes, see the article Record Field Exchange: Using the RFX Functions instead.

The DFX global functions exchange data between columns (fields) on the data source and field data members in your recordset. Normally you use ClassWizard to write the DFX function calls in your recordset’s member function. This article describes the functions briefly and shows the data types for which DFX functions are available. describes how to write your own DFX functions for additional data types.

DFX Function Syntax

Each DFX function takes three parameters (and some take an optional fourth or fifth parameter):

  • A pointer to a object. You simply pass along the pFX pointer passed to DoFieldExchange.

  • The name of the column (field) as it appears in the data source. The names in your SQL statement must match those in the DFX call. Advanced programmers might want to qualify the column names, for example by adding aggregate functions or other SQL modifications. For general guidelines, see the article Recordset: Obtaining SUMs and Other Aggregate Results (ODBC) (the article is for the MFC ODBC classes, but the general principles it illustrates apply as well to DAO). You can also add GROUP BY and other clauses to your SQL, either in the SQL statement or in the DFX function calls. The column (field) name, and any modifications to it, are used to build a query.

  • The name of the corresponding field data member or parameter data member in the recordset class.

  • (Optional) In some of the functions, which handle variable-length data, your specification of how much memory to preallocate for the data. For details, see , , and .

  • (Optional) A flag that specifies whether the field is to be double buffered. For more information, see and the article DAO Record Field Exchange: Double Buffering Records.

For more information, see under Macros and Globals in the Class Library Reference.

DFX Data Types

The class library supplies DFX functions for transferring many different data types between the data source and your recordsets. The following list summarizes the DFX functions by data type. In cases where you must write your own DFX function calls, select from these functions by data type.

Data Types and DFX Functions

DFX function C++ data type DAO data type
DAO_BYTES
BOOL DAO_BOOL
BYTE DAO_BYTES
DAO_CURRENCY
DAO_DATE
double DAO_R8
long DAO_I4
or * DAO_BYTES
short DAO_I2
float DAO_R4
* DAO_CHAR

****Note   ****Mapping long binary objects, such as pictures or OLE objects, to CByteArray is now preferred over mapping them to class . DFX_Text maps between CString and DAO_WCHAR if the symbol _UNICODE is defined. gives you easier control over the contents of the long binary object.

****Note   ****You can use DFX to bring data of a DAO type into a variable of a different type as long as a conversion exists between the two. Take care, however, in cases such as converting a string to a date. If the string doesn’t parse to a correct date format, an error will result.

For information about the DAO data types in the third column of the table Data Types and DFX Functions, see the topic "Type Property" in DAO Help. For more information about the DFX functions in the first column of that table, see under Macros and Globals in the Class Library Reference.

Also in the Class Library Reference see and .

See Also   DAO: Where Is..., DAO Record Field Exchange (DFX), DAO Record Field Exchange: Using DFX, DAO Record Field Exchange: Working with the Wizard Code, DAO Record Field Exchange: Using the DFX Functions, DAO Record Field Exchange: How DFX Works, DAO Queries: Filtering and Parameterizing Queries, DAO Recordset