CRecordView, finding and scrolling
-
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?
-
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?
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
-
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
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
-
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
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
-
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
"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? ;)