Freigeben über


CDaoRecordView Class

A view that displays database records in controls.

class AFX_NOVTABLE CDaoRecordView : public CFormView

Members

Protected Constructors

Name

Description

CDaoRecordView::CDaoRecordView

Constructs a CDaoRecordView object.

Public Methods

Name

Description

CDaoRecordView::IsOnFirstRecord

Returns nonzero if the current record is the first record in the associated recordset.

CDaoRecordView::IsOnLastRecord

Returns nonzero if the current record is the last record in the associated recordset.

CDaoRecordView::OnGetRecordset

Returns a pointer to an object of a class derived from CDaoRecordset. ClassWizard overrides this function for you and creates the recordset if necessary.

CDaoRecordView::OnMove

If the current record has changed, updates it on the data source, then moves to the specified record (next, previous, first, or last).

Remarks

The view is a form view directly connected to a CDaoRecordset object. The view is created from a dialog template resource and displays the fields of the CDaoRecordset object in the dialog template's controls. The CDaoRecordView object uses dialog data exchange (DDX) and DAO record field exchange (DFX) to automate the movement of data between the controls on the form and the fields of the recordset. CDaoRecordView also supplies a default implementation for moving to the first, next, previous, or last record and an interface for updating the record currently in view.

Note

The DAO database classes are distinct from the MFC database classes based on Open Database Connectivity (ODBC). All DAO database class names have the "CDao" prefix. You can still access ODBC data sources with the DAO classes; the DAO classes generally offer superior capabilities because they use the Microsoft Jet database engine.

The most common way to create your record view is with the Application Wizard. The Application Wizard creates both the record view class and its associated recordset class as part of your skeleton starter application.

If you simply need a single form, the Application Wizard approach is easier. ClassWizard lets you decide to use a record view later in the development process. If you don't create the record view class with the Application Wizard, you can create it later with ClassWizard. Using ClassWizard to create a record view and a recordset separately and then connect them is the most flexible approach because it gives you more control in naming the recordset class and its .H/.CPP files. This approach also lets you have multiple record views on the same recordset class.

To make it easy for end-users to move from record to record in the record view, the Application Wizard creates menu (and optionally toolbar) resources for moving to the first, next, previous, or last record. If you create a record view class with ClassWizard, you need to create these resources yourself with the menu and bitmap editors.

For information about the default implementation for moving from record to record, see IsOnFirstRecord and IsOnLastRecord and the article Using a Record View, which applies to both CRecordView and CDaoRecordView.

CDaoRecordView keeps track of the user's position in the recordset so that the record view can update the user interface. When the user moves to either end of the recordset, the record view disables user interface objects — such as menu items or toolbar buttons — for moving further in the same direction.

For more information about declaring and using your record view and recordset classes, see "Designing and Creating a Record View" in the article Record Views. For more information about how record views work and how to use them, see the article Using a Record View. All the articles mentioned above apply to both CRecordView and CDaoRecordView.

Inheritance Hierarchy

CObject

CCmdTarget

CWnd

CView

CScrollView

CFormView

CDaoRecordView

Requirements

Header: afxdao.h

See Also

Reference

CFormView Class

Hierarchy Chart

CDaoRecordset Class

CDaoTableDef Class

CDaoQueryDef Class

CDaoDatabase Class

CDaoWorkspace Class

CFormView Class