“下一条”按钮的代码:
Private Sub Command2_Click()
Set re2 = New ADODB.Recordset
re2.Open "select * from tushu where 编号='" & Text1.Text & "'", cnn, adOpenStatic, adLockPessimistic
If re2.EOF Then
re2.MoveNext
Text1.Text = re2.Fields("编号").Value
Text2.Text = re2.Fields("条形码").Value
Text3.Text = re2.Fields("书名").Value
Text4.Text = re2.Fields("作者").Value
Text5.Text = re2.Fields("出版社").Value
Text6.Text = re2.Fields("类别").Value
Text7.Text = re2.Fields("现存数量").Value
Text8.Text = re2.Fields("图书总数").Value
Text9.Text = re2.Fields("存放位置").Value
Text10.Text = re2.Fields("入馆时间").Value
Text11.Text = re2.Fields("价格").Value
End If
End Sub
以上程序哪错了?
点下一条时没反映!

解决方案 »

  1.   

    刚才写错了,代码应该是这样的:
    Private Sub Command2_Click()
    Set re2 = New ADODB.Recordset
    re2.Open "select * from tushu where 编号='" & Text1.Text & "'", cnn, adOpenStatic, adLockPessimistic
    If re2.EOF Then
    re2.MoveNext
    else
    re2.Movefirst
    End If
    Text1.Text = re2.Fields("编号").Value
    Text2.Text = re2.Fields("条形码").Value
    Text3.Text = re2.Fields("书名").Value
    Text4.Text = re2.Fields("作者").Value
    Text5.Text = re2.Fields("出版社").Value
    Text6.Text = re2.Fields("类别").Value
    Text7.Text = re2.Fields("现存数量").Value
    Text8.Text = re2.Fields("图书总数").Value
    Text9.Text = re2.Fields("存放位置").Value
    Text10.Text = re2.Fields("入馆时间").Value
    Text11.Text = re2.Fields("价格").Value
    End Sub
      

  2.   

    Private Sub Command2_Click()
    Set re2 = New ADODB.Recordset
    re2.Open "select * from tushu where 编号='" & Text1.Text & "'", cnn, adOpenStatic, adLockPessimistic
    If re2.EOF Then
    re2.Movefirst
    else
    re2.Movenext
    End If
    Text1.Text = re2.Fields("编号").Value
    Text2.Text = re2.Fields("条形码").Value
    Text3.Text = re2.Fields("书名").Value
    Text4.Text = re2.Fields("作者").Value
    Text5.Text = re2.Fields("出版社").Value
    Text6.Text = re2.Fields("类别").Value
    Text7.Text = re2.Fields("现存数量").Value
    Text8.Text = re2.Fields("图书总数").Value
    Text9.Text = re2.Fields("存放位置").Value
    Text10.Text = re2.Fields("入馆时间").Value
    Text11.Text = re2.Fields("价格").Value
    End Sub
    If re2.EOF Then
    re2.Movefirst
    else
    re2.Movenext
    End If
      

  3.   

    If re2.EOF Then
    else
    re2.Movenext
    End If
      

  4.   

    Private Sub Command2_Click()
    Set re2 = New ADODB.Recordset
    If re2.State = adStateOpen Then
    re2.Close
    End If
    re2.Open "select * from tushu where 编号='" & Text1.Text & "'", cnn, adOpenStatic, adLockPessimistic
    If re2.EOF Then
    re2.MoveFirst
    Else
    re2.MoveNext
    End If
    Text1.Text = re2.Fields("编号").Value
    Text2.Text = re2.Fields("条形码").Value
    Text3.Text = re2.Fields("书名").Value
    Text4.Text = re2.Fields("作者").Value
    Text5.Text = re2.Fields("出版社").Value
    Text6.Text = re2.Fields("类别").Value
    Text7.Text = re2.Fields("现存数量").Value
    Text8.Text = re2.Fields("图书总数").Value
    Text9.Text = re2.Fields("存放位置").Value
    Text10.Text = re2.Fields("入馆时间").Value
    Text11.Text = re2.Fields("价格").Value
    End Sub
    以上已经关闭了,可还是错的!
    错误提示如下:
    BOF或EOF中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。
    什么意思啊 ?不懂,请高手纠正一下!
    如果不知道错哪?就请帮我写出正确的代码!急……………………………………
    谢!