Access 2007 Search Button
我在尝试使其工作时遇到麻烦,我有一个输入框可以在我的表中找到一个帐号,但是我希望它继续保持该帐号的位置,因为我的表中有多个一行具有相同的帐号。这是我目前拥有的,但是我无法弄清楚如何用相同的帐号查找下一条记录。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | Dim strAccount As String Dim rstQA As Recordset strAccount = InputBox("Enter Account Number") If strAccount ="" Then Exit Sub Set rstQA = Me.Recordset.Clone rstQA.FindFirst"[Account Number]='" & strAccount &"'" If rstQA.NoMatch Then MsgBox"No record of account" Else Me.Bookmark = rstQA.Bookmark End If rstQA.Close Set rstQA = Nothing |
假设您想以表格形式显示匹配的帐户,最好的选择可能是过滤表格:
1 2 3 4 5 6 7 | Dim strAccount As String strAccount = InputBox("Enter Account Number") If strAccount ="" Then Exit Sub Me.Filter "[Account Number]='" & strAccount &"'" Me.FilterOn = -1 |
要返回未过滤的代码,请使用单独的按钮:
1 2 | Me.Filter ="" Me.FilterOn = 0 |
别忘了将"搜索"和"取消过滤"按钮放在表单的页眉或页脚中,否则,如果过滤器不返回任何记录,则您将具有空白表单。