Bookmark and Bookmarkable Properties Example (VC++)

This example shows how you can save your place in a Recordset by saving a bookmark. Once saved, this bookmark can be applied to the Bookmark property to reposition the current record pointer to any location in the Recordset. The FindYear function works with the Biblio.mdb database. It looks up all titles in a given Recordset published in a given year and fills a string array with the bookmarks of any records that match.

int FindYear(int intYear, CdbRecordset &rstBooks,
         CdbBookmark *abkRecord)
{
   int intCount = 0;
   CString   strCriteria;
   //
   strCriteria.Format(
         _T("[Year Published] = %d"), intYear );
   rstBooks.FindFirst(strCriteria);
   while (!rstBooks.GetNoMatch() &&
             rstBooks.GetBookmarkable())
   {
      abkRecord[intCount++] = rstBooks.GetBookmark();
      rstBooks.FindNext(strCriteria);
   }
   return intCount;
}