Hi,

I want to serach records from the record set i hv created in the following code.This record set
Contains values such as

DD Admin-1
DD Admin-2
D-1
D-2
AD-1
AD-2

I just want to match these fields wid the "combo box value" n as in the example i gave the letters
b4 "-" can be same,so first i hv to extract the fields which hv same letters b4 - n then to find out
the last no.Such as first i found

D-1
D-2

thn i hv to check the max no..in this case it is 2..
So kindly tell me where is the problem in this code as it is giving error on "rs.BOF"
VB Code:
  1. Public Sub Designation()
  2. Dim find_value As String
  3. Set conn = New clsConnection
  4. Set rs = New ADODB.Recordset
  5.  
  6. Dim count_value As Integer
  7.  
  8. Dim results As String
  9. Dim index As String
  10. Dim no As String
  11.  
  12.  
  13.  
  14.  
  15. conn.clsOpen
  16. find_value = "SELECT Designation from System_Users;"
  17. rs.Open find_value, conn.cn, adOpenDynamic, adLockBatchOptimistic
  18. 'count_value = rs.Fields.Count
  19.  
  20. rs.BOF
  21. If Not rs.EOF Then
  22.  
  23.       Do While Not rs.EOF
  24.         'type_value = rs("Type_Name")
  25.           ' Form4.cmbID.AddItem type_value
  26.        
  27.            results = rs.find("form4.cmbRank.text", adSearchForward)
  28.            index = InStr(index, "-")
  29.            no = Left(results, Len(results) - index)
  30.            MsgBox no, vbOKOnly, "ALERT"
  31.             rs.MoveNext
  32.            
  33.       Loop
  34.  
  35.   End If
  36.   MsgBox results(index), vbOKOnly, "ALERT"
  37.  
  38.  
  39.   conn.clsClose
  40.      
  41. End Sub

Waiting for ur urgent reply

Regards,