PDA

Click to See Complete Forum and Search --> : Search a rec in a recordset


trisLOGIC
May 13th, 2000, 12:41 AM
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

Mongo
May 13th, 2000, 01:18 AM
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