Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2004
    Location
    Laguna, Philippines
    Posts
    147

    Unanswered: Who is faster in searching a record?

    i am just curious, if i will search a record in a table which of the three is advisable and faster to use and why? and if you have any more algorithms that is faster than the three please tell me too.

    rs.open "select * from [Table] where [field] = '" & key & "';"

    if rs.eof or rs.recordcount = 0 then
    'no record...
    else
    'record found...
    end if

    or...

    rs.open "select * from [Table];"
    rs.find "[field] = '" & key & "'"

    if rs.eof then
    'no record...
    else
    'record found...
    end if

    or...

    rs.open "select * from [Table];"

    do while not rs.eof
    if rs(field) = key then
    'record found...
    exit sub
    end if
    rs.movenext
    loop

    if rs.eof then
    'no record...
    end if

    thanks....
    Last edited by coleone; 01-31-05 at 21:35.
    Give me a place to code and i shall move the earth!

  2. #2
    Join Date
    Nov 2004
    Posts
    30
    Obviously the First one since it will retrieve only the record which u need.
    The second 1 retrieves all the records and you have to use find again.
    The third is the worst since you retrieve all the records and loop and search each record .

  3. #3
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    421
    Yep the first option, tho mosttimes a key value is a number instead of a text value.

    Regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •