Text1.Text = adoPrimaryRS.Fields.Item(0).Value其中text1是一个文本框
adoPrimaryRS.Fields.Item(0).Value 取出的是当前记录指针一个属性的value我要实现的是:
首先记录指针指向第一条记录,
Text1.Text和adoPrimaryRS.Fields.Item(0).Value相比较,如果值不同则movenext,如果值相同则查找成功,将记录指针定格在当前记录上。
呵呵,我basic不行,不知道代码怎么写,请帮帮我,谢谢。
这是关于adoPrimaryRS的定义:
Dim WithEvents adoPrimaryRS As Recordset
谢谢了!
这是我剪的几段代码:
Dim test1 As Boolean
 test1 = Not (Text1.Text = adoPrimaryRS.Fields.Item(0).Value)
 
 
 On Error GoTo GoNextError
Do While (1)
  
  
  
  If Not adoPrimaryRS.EOF Then adoPrimaryRS.MoveNext
  If adoPrimaryRS.EOF And adoPrimaryRS.RecordCount > 0 Then
    Beep
     '已到最后返回
    adoPrimaryRS.MoveLast
  End If
  '显示当前记录
If test1 Then
   End If
GoNextError:
  MsgBox Err.Description请帮帮我啊!
 
 
 Loop

解决方案 »

  1.   

    查找一般用两种方式
       1:把条件直接写在sql语句中
          rs as new Recordset
          rs.cursorlocation=aduseclient'客户端游标
          rs.open "select * from tablename where field1="+text1.text,cn,......
          if re.recordcount<>0 then'表示有符合条件的数据,当然包括所有符合条件的数据   2:有find
          rs as new recordset
          rs.cursorlocation=aduseclient'客户端游标
          rs.open "select * from tablename",cn,.........
          if rs.recordcount=0 then exit sub'没有数据,退出
              rs.movefirst'移动到第一条记录
              rs.find "fiked1="+"'"+text1.text+"'"
              if not rs.eof then'找到一条
                            end if
        与do while 配合使用可以一条一条地向下找
              
      

  2.   

    adoprimaryrs.movefirst
    for i = 1 to adoprimaryrs.recordcount 
     if text1.text= adoprimaryrs.fields(0).value then
       msgbox "查找成功,当有记录是:"& i
      exit for
      endif
      adoprimaryrs.movenext 
    next i