在MsAccess表单中按“显示全部”按钮后删除关键字

时间:2018-07-11 01:15:38

标签: forms ms-access events search keyword-search

请忽略,只是找到了答案:

目前,在我的MsAccess表单中:

  Keywords window - where I can type text to look up records, by the Client Name,
  Search button - after pressing on it I can see the search results
  Show All button - after pressing on which I see all the records 

当前,在按 Show All (全部显示)后,我在 Keywords (关键字)窗口中键入的内容都会保留在那里。我希望每次我按下 Show All (全部显示)按钮

是否有可能得到这样的结果? 如果是,该怎么办或-如何修改事件程序?

以下是我的活动程序代码: btn_Search_Click()-通过ceratin关键字进行搜索 btn_ShowAll_Click()-显示所有记录

Option Compare Database
Option Explicit

Private Sub btn_Search_Click()

Dim strsearch As String
Dim strText As String
strText = Me.TxtKeywords.Value
strsearch = "SELECT * from qry_Clients 
where ((ClientName LIKE ""*" & strText & "*"") OR(MedRecNumber LIKE ""*" & 
strText & "*""))"
Me.RecordSource = strsearch

End Sub

Private Sub btn_ShowAll_Click()

Dim strsearch As String
strsearch = "SELECT * from qry_Clients"
Me.RecordSource = strsearch

End Sub

谢谢!

1 个答案:

答案 0 :(得分:0)

对不起,但我刚刚找到了答案! 为了能够在点击“显示全部”按钮后清除文本框, 我必须将最后一个字符串添加到我的

Private Sub btn_ShowAll_Click():

Me.TxtKeywords = ""