我在 Access 2007 中有一个数据库,我目前正在为文本搜索框使用以下代码。我的问题是,如果在搜索框中输入了整个名称,它只会找到记录。对于企业名称,我希望用户能够输入企业的第一个单词并检索表单上的记录。目前,如果我输入名字,它会说找不到记录。我必须输入整个公司名称。有人可以帮我根据需要调整此代码吗?
私有子 txtsrch_AfterUpdate()
If (txtsrch & vbNullString) = vbNullString Then Exit Sub
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "[lastname]=""" & txtsrch & """"
If rs.NoMatch Then
MsgBox "Sorry, no such record '" & txtsrch & "' was found.", _
vbOKOnly + vbInformation
Else
Me.Recordset.Bookmark = rs.Bookmark
End If
rs.Close
txtsrch = Null
结束子
谢谢你。