Results 1 to 6 of 6

Thread: Using that FIND command with ADODB

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    canada
    Posts
    15

    Post

    This is the syntax the words in brackets are optional but I had problem leaving blanks so I used them.


    Recordset.Find(Criteria As String, [SkipRecords As Long], [SearchDirection As SearchDirectionEnum = adSearchForward], [Start])

    Criteria is a string with operators like 'EMP_NAME = DAVE' and you can use wild card operators as well like ? and *.

    SkipRecords is self-explanatory

    SearchDirection is self-explanatory

    Start is where to start like adBookmarkFirst then you must logicaly use adSearchForward since you are at the first record of the Recordset.

    Make sure that your recordset cursor type is not adForwardOnly meaning that you can only advance in the record set.

    Hope this will help


  2. #2
    Guest

    Post

    Wherever possible I avoid the .FIND method because it is too dang slow. I use sql SELECT instead.

  3. #3
    Member
    Join Date
    Sep 1999
    Location
    UK
    Posts
    45

    Post

    Anyone know how to use that find command with ADODB to search through your open database???

  4. #4
    Member
    Join Date
    Sep 1999
    Location
    UK
    Posts
    45

    Post

    How do you use find select with sql?

  5. #5
    Guest

    Post

    Whatever your .FIND criteria is you can phrase as a SELECT statement, e.g., Recordset.FIND "FIELD = " & value can be rephrased "SELECT Recordset.* WHERE (FIELD = " & value. Then execute the SELECT phrase as a command.EXECUTE or recordset.OPEN(sql)

    .FIND is a sequential search going forward or backward according to the parameters VBfreak mentioned. SELECT is much more direct utilizing table indices.

  6. #6
    Junior Member
    Join Date
    Nov 1999
    Location
    Muscatine, Iowa, USA
    Posts
    18

    Post

    Hi steviep,
    The following code works for me!

    If strLastName <> "" Then
    'Search forward for the CustomerID
    datPrimaryRS.Recordset.Find "LAST_NAME = '" & strLastName & "'", 0, adSearchForward

    'If the record isn't found, we will be at the end of the recordset.

    The strLastName is just a string from a text box and this code is placed under the click area of a command button.
    Jim
    'So, reposition the recordset back to the record we came from and search backwards.
    If datPrimaryRS.Recordset.EOF Then
    datPrimaryRS.Recordset.Bookmark = mybkmark
    datPrimaryRS.Recordset.Find "LAST_NAME = '" & strLastName & "'", 0, adSearchBackward

    'If we don't find the record this time, it doesn't exist.
    'So, reposition the recordset back to the record we came from and tell the user.
    If datPrimaryRS.Recordset.BOF Then
    datPrimaryRS.Recordset.Bookmark = mybkmark
    MsgBox "Record Not Found"
    End If
    End If
    End If

Posting Permissions

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



Click Here to Expand Forum to Full Width