Results 1 to 2 of 2

Thread: Search a rec in a recordset

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Location
    Malaysia
    Posts
    69
    Is there a method that I can use to determine whether a value exist in one of my table in the recordset and return true if so, otherwise false.

    The method seek and find in ADO only adjust the row to point to that record.

    I tried to write a global function to perform the task but don't know why fail.

    Public Function RstSeek(rst As ADODB.Recordset, field As ADODB.field, value As String)
    RstSeek = False

    rst.MoveFirst
    Do While Not rst.EOF
    If (rst!field = value) Then
    RstSeek = True
    Exit Do
    End If
    rst.MoveNext
    Loop
    End Function

    Is there something wrong with my code ? The program halted at the rst!field saying that it could not determine the object.

    Thx

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Leavenworth KS USA
    Posts
    482
    Two ideas.

    1. Add "As Boolean" to your function def.
    Public Function RstSeek(rst As ADODB.Recordset, field As ADODB.field, value As String) As Boolean

    2. I would guess your recordset's field name is something other than "field"
    If (rst![the_field_name_here] = value) Then


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