Private Sub Command4_Click()
Dim dd As Database
Dim nn As Recordset
Set dd=OpenDatabase("d:\数据库.mdb")
Set nn=dd.OpenRecordset("表",dbOpenTable)
msg$="请输入要查的书名!"
nn.Index=书名
s$=InputBox(msg$,"查询")
nn.Seek "=", s$
If nn.NoMatch Then
MsgBox "没有你要找的书!",16,"没找到"
Data1.Recordset.MoveFirst
Else
MsgBox "所查到的书号为" & nn!书号,48,"查找成功!"
End If
End Sub
原来是 nn.Index="书名",结果去掉了引号才通过此语句。字段名为 书名 没有错。