Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CRecordView, finding and scrolling

CRecordView, finding and scrolling

Scheduled Pinned Locked Moved C / C++ / MFC
saleshelpquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anders Gustafsson
    wrote on last edited by
    #1

    Hi! I am working with a class, derived from CRecordView. It is a basic customer-maintenance type module where you can either select the record by typing in the key number or scroll back and forth, uisng the standard RecordView buttons. Problem is that quick lookups and scrolling appears to me mutually exclusive. The person who originally wrote the class solved this by coding the lookup like this: MoveFirst(); while(!IsEOF()) { if(m_Nummer==nr) return TRUE; MoveNext(); } This works if the number of records are reasonable (say up to 5000). If I code the lookup with a normal filter and Requery then it is lightinly fast, but Moves fail, presumably because it tries to move within that result set of one record. Can anyone suggest a solution where I can: a) Just type in a number and have it pull up the record and b) be able to use previous/next navigation?

    D 1 Reply Last reply
    0
    • A Anders Gustafsson

      Hi! I am working with a class, derived from CRecordView. It is a basic customer-maintenance type module where you can either select the record by typing in the key number or scroll back and forth, uisng the standard RecordView buttons. Problem is that quick lookups and scrolling appears to me mutually exclusive. The person who originally wrote the class solved this by coding the lookup like this: MoveFirst(); while(!IsEOF()) { if(m_Nummer==nr) return TRUE; MoveNext(); } This works if the number of records are reasonable (say up to 5000). If I code the lookup with a normal filter and Requery then it is lightinly fast, but Moves fail, presumably because it tries to move within that result set of one record. Can anyone suggest a solution where I can: a) Just type in a number and have it pull up the record and b) be able to use previous/next navigation?

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Anders Gustafsson wrote:

      ...Moves fail, presumably because it tries to move within that result set of one record.

      Have you tried checking IsBOF() also?

      "Love people and use things, not love things and use people." - Unknown

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      A 1 Reply Last reply
      0
      • D David Crow

        Anders Gustafsson wrote:

        ...Moves fail, presumably because it tries to move within that result set of one record.

        Have you tried checking IsBOF() also?

        "Love people and use things, not love things and use people." - Unknown

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        A Offline
        A Offline
        Anders Gustafsson
        wrote on last edited by
        #3

        Yes. If I set m_strFilter and do a requery, I find my record. I then clear m_strFilter. If I then hit previous/next the framework will kick off an extended fetch that will error with 100 (SQL No DATA). What does work, but is kind of ugly is this: Open the table, scroll through all records, for each do a: m_pSet->GetStatus(rStatus); m_Index[m_pSet->m_Nummer] = rStatus.m_lCurrentRecord + 1; This builds an index of all records and their absolute numbers. Then in my lookup routine: m_pSet->m_strFilter = "Nummer=?"; m_pSet->m_Nummerfilter = m_persGrund.m_persnrEdit.m_set.m_Nummer; m_pSet->Requery(); m_pSet->m_strFilter = ""; m_pSet->Requery(); m_pSet->SetAbsolutePosition(m_Index[m_persGrund.m_persnrEdit.m_set.m_Nummer]); But this seems like a tremenous kludge for such a simple task?

        modified on Monday, May 12, 2008 3:16 PM

        D 1 Reply Last reply
        0
        • A Anders Gustafsson

          Yes. If I set m_strFilter and do a requery, I find my record. I then clear m_strFilter. If I then hit previous/next the framework will kick off an extended fetch that will error with 100 (SQL No DATA). What does work, but is kind of ugly is this: Open the table, scroll through all records, for each do a: m_pSet->GetStatus(rStatus); m_Index[m_pSet->m_Nummer] = rStatus.m_lCurrentRecord + 1; This builds an index of all records and their absolute numbers. Then in my lookup routine: m_pSet->m_strFilter = "Nummer=?"; m_pSet->m_Nummerfilter = m_persGrund.m_persnrEdit.m_set.m_Nummer; m_pSet->Requery(); m_pSet->m_strFilter = ""; m_pSet->Requery(); m_pSet->SetAbsolutePosition(m_Index[m_persGrund.m_persnrEdit.m_set.m_Nummer]); But this seems like a tremenous kludge for such a simple task?

          modified on Monday, May 12, 2008 3:16 PM

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Anders Gustafsson wrote:

          I then clear m_strFilter. If I then hit previous/next...

          Since the record has been found, why?

          "Love people and use things, not love things and use people." - Unknown

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          A 1 Reply Last reply
          0
          • D David Crow

            Anders Gustafsson wrote:

            I then clear m_strFilter. If I then hit previous/next...

            Since the record has been found, why?

            "Love people and use things, not love things and use people." - Unknown

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            A Offline
            A Offline
            Anders Gustafsson
            wrote on last edited by
            #5

            "Since the record has been found, why?" You mean "Why hit previous/next" possibly after I have edited and saved? To go to th enext record. Anyway, that is what users do, don't they? ;)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups