根据部分文本在 MS Access 表单中搜索记录

Search an MS Access form for a record based on partial text

使用表单向导创建组合框时,可以select根据组合框selection创建一个表单记录。我想从文本框中做类似的事情,但我希望它搜索部分字符串。我这样调整了表单向导代码:

Private Sub txtSearchString_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object
    Set rs = Me.Recordset.Clone
    rs.FindFirst "[RequestName] LIKE *" & Str(Nz(Me![txtSearchString], 0)) & "*"
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

我收到“类型不匹配”错误。我的代码有问题还是 FindFirst 函数无法做到这一点?

尝试以下方法

   Dim rs As Object
   Set rs = Me.Recordset.Clone
   rs.FindFirst "[RequestName] LIKE '*" & Me.txtSearchString & "*'"
   If Not rs.EOF Then Me.Bookmark = rs.Bookmark