FIX: "Operation failed, no current record" Message

Last reviewed: September 18, 1997
Article ID: Q118759
1.00 1.50 WINDOWS kbprg kbfixlist kbbuglist

The information in this article applies to:

   The Microsoft Foundation Classes (MFC), included with:
    - Microsoft Visual C++ for Windows, versions 1.0 and 1.5

SYMPTOMS

In an MFC database application that uses CRecordsets, open a recordset with a query that will result in at least two records. Call Delete() to delete one of the records. Call Requery() to regenerate the recordset. Now call Edit() or Delete() and you will see something similar to the following in the output window:

    DBMS: ACCESS, Version: 1.1
    Operation failed, no current record.
    Warning: Throwing an Exception of type CDBException
    Error: Un-caught Exception (CDBException)
    AfxTerminate called
    AfxAbort called

CAUSE

This message occurs because Requery() does not reset the m_bDeleted variable that is set when you call Delete(). When you call Edit() or Delete() after the Requery(), m_bDeleted is checked and if it is TRUE, the application assumes that there is no valid current record.

RESOLUTION

To correct the bug, override CRecordset::Requery() in your derived CRecordset class and reset the m_bDeleted member to FALSE. In the "MORE INFORMATION" section, below, is an example of an overridden Requery().

STATUS

Microsoft has confirmed this to be a bug in the Microsoft Foundation Classes, versions 2.0 and 2.5. This bug was corrected in MFC version 2.51, included with Visual C++ version 1.51.

MORE INFORMATION

Sample Code

   // CMyRecordset is derived from CRecordset.

   BOOL CMyRecordset::Requery()
   {
       m_bDeleted=FALSE;
       return CRecordset::Requery();
   }


Additional reference words: 1.00 1.50 2.00 2.50 record set
KBCategory: kbprg kbfixlist kbbuglist
KBSubcategory: MfcDatabase
Keywords : kb16bitonly MfcDatabase kbbuglist kbfixlist kbprg
Technology : kbMfc
Version : 1.00 1.50
Platform : WINDOWS
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 18, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.