Microsoft KB Archive/145686

= PRB: CDaoRecordView Bookmark Members Invalid After Requery =

Article ID: 145686

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 4.2 Enterprise Edition

 Microsoft Visual C++ 4.2 Enterprise Edition

 Microsoft Visual C++ 5.0 Enterprise Edition

 Microsoft Visual C++ 6.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 4.0 Professional Edition</li></ul>

 Microsoft Visual C++ 4.1 Subscription</li></ul>

 Microsoft Visual C++ 4.2 Professional Edition</li></ul>

 Microsoft Visual C++ 4.2 Professional Edition</li></ul>

 Microsoft Visual C++ 5.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 5.0 Learning Edition</li></ul>

 Microsoft Visual C++ 5.0 Learning Edition</li></ul>

<ul> <li>Microsoft Visual C++, 32-bit Learning Edition 4.2b</li></ul>

<ul> <li>Microsoft Visual C++ 6.0 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q145686

<div class="symptoms_section">

SYMPTOMS
In some cases, when you use CDaoRecordView, added records will not show up in the result set after calling Requery on the CDaoRecordset.

<div class="cause_section">

CAUSE
CDaoRecordView uses Jet engine bookmarks to determine when you are on the first or last record of the related CDaoRecordset. Jet engine bookmarks are not guaranteed to be valid following a Requery.

<div class="resolution_section">

RESOLUTION
To avoid the problem, re-initialize the CDaoRecordView bookmark members to indicate that they are not valid bookmark values following any Requery on the related CDaoRecordset. The following example shows how this might be done in a CDaoRecordView-derived class's OnMove function: BOOL CMyRecordView::OnMove(UINT nIDMoveCommand) {     CDaoRecordset* pRecordset = OnGetRecordset; if (m_bAddMode) {        if (!UpdateData) return FALSE; try {           pRecordset->Update; }        catch (CDaoException* e)         { AfxMessageBox(e->m_pErrorInfo->m_strDescription); e->Delete; return FALSE; }

pRecordset->Requery;

m_varBookmarkCurrent = 1L;  // <<- re-initialize m_varBookmarkFirst =        // <<- the bookmark m_varBookmarkLast = 0L;  // <<- member variables!

UpdateData(FALSE); m_bAddMode = FALSE; return TRUE; }     else {        return CDaoRecordView::OnMove(nIDMoveCommand); }  } If you call Requery in any other case from your CDaoRecordView-derived class, you should also perform this re-initialization.

<div class="status_section">

STATUS
This behavior is by design.

Keywords: kbdatabase kbprb kbusage KB145686

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.