|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ADO Recordset Find method ProblemI have a Recordset RST with two rows with the same Data like follows: Company 1. ABC 2. ABC Now I use RST.Find "Company="ABC" to find the Record. After finding the first record. I would like to find the second record use find too. The code is as follows: RST.Find "Company="ABC" RST.Find "Company="ABC" But I found that in when the Second Find executes. The RST still points to the first record. It does not move to the second Record. Is find method can only find one record and cannot find next record. Or there are somethings I need to set in the RST properties just like CursorLocation in order to make the find can move to the second Record. Thanks
Show quote
Hide quote
"hon123456" <peterhon***@yahoo.com.hk> wrote in message The ADO Find method takes 4 parameters.news:a5b1a0ed-d903-4013-91bc-3dec10d5a290@g1g2000pra.googlegroups.com... > Dear all, > > I have a Recordset RST with two rows with the same Data > like follows: > > > Company > > 1. ABC > 2. ABC > > Now I use RST.Find "Company="ABC" to find the Record. After > finding the first record. > I would like to find the second record use find too. The code is as > follows: > > RST.Find "Company="ABC" > RST.Find "Company="ABC" > > But I found that in when the Second Find executes. The RST still > points to the first record. It does not move to the second Record. Is > find method can only find one record and cannot find next record. Or > there are somethings I need to set in the RST properties just like > CursorLocation > in order to make the find can move to the second Record. > http://msdn.microsoft.com/en-us/library/ms917727.aspx Thanks Ralph
Use all 4 parameters , but Find still not move to the second record. RST.Find "Company = 'ABC', 0, adSearchForward, 0 Please help. Thanks On 2?$B7n?(B20?$BF|?(B, ?$B2<8a?(B1?$B;~?(B50?$BJ,?(B, hon123456 <peterhon***@yahoo.com.hk> wrote:
> Thanks Ralph Since my recordset is using adUseClient CursorLocation. So is that> > Use all 4 parameters , but Find still not move to the second record. > > RST.Find "Company = 'ABC', 0, adSearchForward, 0 > > Please help. > > Thanks mean I need to install MDAC 2.8 to let Find method work. And include the MDAC in my project to Find method work. Or some other setting that I need to set . Thanks On 2?$B7n?(B20?$BF|?(B, ?$B2<8a?(B2?$B;~?(B35?$BJ,?(B, hon123456 <peterhon***@yahoo.com.hk> wrote:
Show quoteHide quote > On 2?$B7n?(B20?$BF|?(B, ?$B2<8a?(B1?$B;~?(B50?$BJ,?(B, hon123456 <peterhon***@yahoo.com.hk> wrote: My window is XP SP2. It does not need to install MDAC. So why> > > Thanks Ralph > > > Use all 4 parameters , but Find still not move to the second record. > > > RST.Find "Company = 'ABC', 0, adSearchForward, 0 > > > Please help. > > > Thanks > > Since my recordset is using adUseClient CursorLocation. So is that > mean I need > to install MDAC 2.8 to let Find method work. And include the MDAC in > my project > to Find method work. Or some other setting that I need to set . > > Thanks recordset find method cannot find the second record? Any Idea? Or Find can only work with Server Cursor location. Thanks On 2?$B7n?(B20?$BF|?(B, ?$B2<8a?(B2?$B;~?(B43?$BJ,?(B, hon123456 <peterhon***@yahoo.com.hk> wrote:
Show quoteHide quote > On 2?$B7n?(B20?$BF|?(B, ?$B2<8a?(B2?$B;~?(B35?$BJ,?(B, hon123456 <peterhon***@yahoo.com.hk> wrote: I discover that Find will only works when it is preceded by> > > > > > > On 2?$B7n?(B20?$BF|?(B, ?$B2<8a?(B1?$B;~?(B50?$BJ,?(B, hon123456 <peterhon***@yahoo.com.hk> wrote: > > > > Thanks Ralph > > > > Use all 4 parameters , but Find still not move to the second record. > > > > RST.Find "Company = 'ABC', 0, adSearchForward, 0 > > > > Please help. > > > > Thanks > > > Since my recordset is using adUseClient CursorLocation. So is that > > mean I need > > to install MDAC 2.8 to let Find method work. And include the MDAC in > > my project > > to Find method work. Or some other setting that I need to set . > > > Thanks > > My window is XP SP2. It does not need to install MDAC. So why > recordset find > method cannot find the second record? Any Idea? Or Find can only work > with Server Cursor location. > > Thanks- ?$Bp,i6Ho0zMQJ8;z?(B - > > - ?$Bp}<(Ho0zMQJ8;z?(B - rst.movefirst or rst.movelast. Find method even will not work after rst.movenext or rst.moveprevious. What should I do to let Find method to move to the second Record. Thanks On 2?$B7n?(B20?$BF|?(B, ?$B2<8a?(B3?$B;~?(B00?$BJ,?(B, hon123456 <peterhon***@yahoo.com.hk> wrote:
Show quoteHide quote > On 2?$B7n?(B20?$BF|?(B, ?$B2<8a?(B2?$B;~?(B43?$BJ,?(B, hon123456 <peterhon***@yahoo.com.hk> wrote: I have find a solution to the problem> > > > > > > On 2?$B7n?(B20?$BF|?(B, ?$B2<8a?(B2?$B;~?(B35?$BJ,?(B, hon123456 <peterhon***@yahoo.com.hk> wrote: > > > > On 2?$B7n?(B20?$BF|?(B, ?$B2<8a?(B1?$B;~?(B50?$BJ,?(B, hon123456 <peterhon***@yahoo.com.hk> wrote: > > > > > Thanks Ralph > > > > > Use all 4 parameters , but Find still not move to the second record. > > > > > RST.Find "Company = 'ABC', 0, adSearchForward, 0 > > > > > Please help. > > > > > Thanks > > > > Since my recordset is using adUseClient CursorLocation. So is that > > > mean I need > > > to install MDAC 2.8 to let Find method work. And include the MDAC in > > > my project > > > to Find method work. Or some other setting that I need to set . > > > > Thanks > > > My window is XP SP2. It does not need to install MDAC. So why > > recordset find > > method cannot find the second record? Any Idea? Or Find can only work > > with Server Cursor location. > > > Thanks- ?$Bp,i6Ho0zMQJ8;z?(B - > > > - ?$Bp}<(Ho0zMQJ8;z?(B - > > I discover that Find will only works when it is preceded by > rst.movefirst or > rst.movelast. Find method even will not work after rst.movenext or > rst.moveprevious. What should I do to let Find method to move to the > second Record. Thanks- ?$Bp,i6Ho0zMQJ8;z?(B - > > - ?$Bp}<(Ho0zMQJ8;z?(B - The code I used is RST.MoveFirst RST.Find "Company="ABC" RST.moveprevious RST.movenext Rst.movenext RST.Find "Company="ABC" Then the find can find the second record. Thanks
Show quote
Hide quote
"hon123456" <peterhon***@yahoo.com.hk> wrote in message Apparently only the first couple of sentances of my post showed up. Afternews:9ec3f340-c40c-4069-82f9-a412d5848807@u39g2000prn.googlegroups.com... > > I have find a solution to the problem > > The code I used is > RST.MoveFirst > RST.Find "Company="ABC" > RST.moveprevious > RST.movenext > Rst.movenext > RST.Find "Company="ABC" > > > Then the find can find the second record. > > Thanks > the link I went on to say ... "This may help, but frankly ADO's .Find method is flacky. It often has trouble determining current record location or where it should start looking from." .... a long winded explanation mercifully snipped as you have already discoverd the common work-arounds, or ugly gyrations, one too often finds themselves forced into doing. To make it worse - subtle differences in behavior will be found with different Providers. It performs it's designed mission of "finding the first record" in a Recordset that has already been opened and "moved into", but even then can fail if the target is the first or last record. Because of this .Find is best avoided for those scenarios where you need to 'find' multiple records. Performance wise you are better off 1) Sorting the original query using an Order By clause. Use .Find for the first record and then loop until the target column is no longer valid. ... ' psuedocode .MoveFirst .Find target While target = "something" DoStuffWithRecord .MoveNext Wend 2) Use ADO's .Sort method, then do the above 3) or re-query the data using the target in a Where clause, then looping through the new Recordset. (Believe it or not - often faster) hth -ralph
Graphic Time Labeling
how to reposition desktop icons WTF happened to my typelibs? How to switch the monitor off through vb6 code? How to Link ADO control to DATAGRID? how to check an ADO recordset status? Common Dialog Font - Color Choices More Regional Setting Woes Visual Basic 6 ActivexDLLs are not registering under Windows Vista Adding a right-click function to a control |
|||||||||||||||||||||||