Article ID: 150122
Article Last Modified on 11/21/2006
m_varBookmarkCurrent m_varBookmarkFirst m_varBookmarkLast m_nStatusThese variables are only maintained when the CDaoRecordView::OnMove method is invoked. This method invokes the CDaoRecordset MoveFirst, MoveNext, MovePrevious, or MoveLast methods, and updates the variables. Only OnMove keeps these variables in synchronization.
- Find - Move - Requery - FindFirst - MoveFirst - Seek - FindLast - MoveLast - SetAbsolutePosition - FindNext - MoveNext - SetBookmark - FindPrev - MovePrev - SetPercentPositionWhen the AddNew method is called, a new record is added to the recordset but the current record bookmark does not change. To change the newly added record to the current record, use the following method:
// set the current bookmark to the newly added record m_pSet->SetBookmark(GetLastModifiedBookmark());NOTE: GetLastModifiedBookmark() needs to be called right after the call to Update() to return the newly added record. Calling it after one of the recordview MoveXXXX functions returns a bookmark to the record that was current prior to the move operation.
if (!m_pSet->Seek(...))
{
if( !m_pSet->IsEOF() )
{
m_varBookmarkCurrent = 1L; // <<- re-initialize
m_varBookmarkFirst = // <<- the bookmark
m_varBookmarkLast = 0L; // <<- member variables!
// Enable toolbar buttons
m_nStatus |= AFX_DAOVIEW_SCROLL_BACKWARD;// First & Prev buttons
m_nStatus |= AFX_DAOVIEW_SCROLL_NEXT; // next toolbar button
m_nStatus |= AFX_DAOVIEW_SCROLL_LAST; // last toolbar button
}
else
{
// Move to some valid record
}
}
else
{
// Seek failed - move to a valid record
}
m_pSet->SetCurrentIndex( _T("PrimaryKey") );
COleVariant varCourse ( _T("MATH201"), VT_BSTRT );
COleVariant varSection( _T( "1" ), VT_BSTRT );
if(! m_pSet->Seek( _T( "=" ), &varCourse, &varSection ) )
{
// Seek failed - need to move to a valid record
m_pSet->MoveFirst();
}
UpdateData( FALSE );
145686 CDaoRecordView Bookmark Members Invalid After Requery()
145719 DAOENROL - Can't See Added Records in Windows 95
Keywords: kbdatabase kbprb kbcode kbusage KB150122