Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb6 - what is equivalant command for find first - ado

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
hai

greetings from india

I have a access db contains 15000 records(rows)
regularly.
i am using "select * from tcc where empcode = 10101"

in this way every time opens the file and
it takes some more time(some min or sec)
process and then
close the file every time.

i want to implement findfirst method
is it possible or not
pl help me
i am using ADO data control

thanks in advance

shanmugham(india)
 
This is the complete find command of an ADO recordset
adodc1.Recordset.find(criteria as String,[skiprecords as Long],[searchdirection as SearchDirectionEnum = adSearchForward],[start]

An example is:

adodc1.Recordset.find "[Author] LIKE 'F*'",0,adSearchForward

find does not support NoMatch property if the find method is unsuccessful the record pointer is positioned at the end of the recordset.
 
ok thanks
i want to find out next match (i.e. find next)

is it works .findnext ???

shanmugham
 
I think it's this:
adodc1.Recordset.find "[Author] LIKE 'F*'",1,adSearchForward
I changed the 0 to 1 in the skiprecords parameter this means it will not stop at the first it finds but the second it finds.

I have not used the find function much you should try it out a little.

 
o.k. thanks
i want to keep searching one by one using find, until eof

for eg, in MS word when we search for a text, the search continues till the end of file, showing all the searched text.

Similarly, in VB say I want to search and list all author names with John, I want the result of the first search, then the next search and so on till the end of the file.

How can I do this?





 


harmmeijer,

Please let me know WHERE you find this. I have looked in SEVERAL references and do not find (no pun intended) this reference to a recordset.find.

This is the complete find command of an ADO recordset
adodc1.Recordset.find(criteria as String,[skiprecords as Long],[searchdirection as SearchDirectionEnum = adSearchForward],[start]


MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Hello

the comments made by MichaelRed are valid, if you just install the vb bits of the MSDN help files you don't seem to get all the ADO help files. What you're looking for under help is Find method, but you may be prompted to install disk 2 of msdn - it all depends on what bits of MSDN you've installed.

As the problem of searching to the end, you need to know whether it's the first search for a value, or subsquent searches. The code below uses a flag (firstSearch) and depending on the value of this it either searches from the current record (first time search) or the next record. You need to move from the next record becuase if you don't vb regards the first "found" record as found the second time round and so doesn't move from this record.


The following code should do it

Private Sub Command1_Click()
'declare firstSearch as boolean variable in
'general declarations section, NOT in this event
'and then set it to true in form_load event.

If firstSearch Then
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.find "[Author] LIKE '*John*'",0,adSearchForward
firstSearch = False
Else
'not the first search for this value so set value to 1
Adodc1.Recordset.find "[Author] LIKE '*John*'",1,adSearchForward
End If


If Adodc1.Recordset.EOF = True Then
'no more matches found
MsgBox "No matches found"
'recordset now on eof so move to existing record
Adodc1.Recordset.MoveFirst
firstSearch = True
End If

End Sub
 
MichaelRed,

The feature that harmmeijer alludes to is covered in the documentation (well, it is mine) - just not very clearly:

SkipRows
Optional. A Long value, whose default value is zero, that specifies the row offset from the current row or Start bookmark to begin the search. By default, the search will start on the current row.

So, untangling that means that if you do a search that successfully finds a match, then it stops at the matched record. Search again, with SkipRows set to 0, and of course it starts searching at the current record and immediately matches it again. Set SkipRow to 1, and we start searching from the NEXT record and stop when we find the next match.

In other words, by switching SkipRows from 0 to 1 after the first search we get a FindNext capability.
 
Well,

At least part of what I'm trying to understand is what 'documentation' I'm MISSING - or at least where to look for it. In my "Help", seardching or indexing on find only comes up with references to DAO dindX methods and the manipulation of the menu item - NO recordset.Find entry. I have the complete? MSDN installed on the local HD, so i'm lost as to WHERE this (and possibly other handy little properties and methods may be lurking (and shirking).

I also hae a couple of third party "advanced" books for VB 6 and Ms. Access 2K - bith of which advertise they cover "ADO" - but without reference to this method!

So, again, PLEASE let me know where I'm supposed to find(PUN Intended) this method in the help system

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Dear MichaelRed

If you bring up the MSDN you should see a listing for Platform SDK, expand that to Database and Messaging Service, then expand that to Microsoft Data Access SDK, then expand that to Microsoft ActiveX Data Objects.

You should then see a listing of ADO welcome and overviews

Kate
 
I got my documentatioon from the same location as Kate.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top