关闭表单时如何清除搜索栏文本 [英] How to clear search bar text when closing form

查看:50
本文介绍了关闭表单时如何清除搜索栏文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有搜索栏和两个按钮的 MainMenu.Button1 在 VIEW only 模式下打开 MainForm、Subform1 和 Subform2,过滤到输入到未绑定搜索栏中的 SchoolID.

I have a MainMenu with a search bar and two buttons. Button1 opens MainForm, Subform1, and Subform2 in VIEW only mode, filtered to the SchoolID typed into the unbound search bar.

我的问题是:当用户通过单击我的 CloseFormOpenMainMenu 按钮返回到 MainMenu 时,我如何清除输入到 MainMenu 搜索栏中的内容并清除过滤器?

My question is: When the user returns to the MainMenu by clicking my CloseFormOpenMainMenu button , how can I clear what is typed into the MainMenu search bar and clear the filter?

这是我在 MainMenu 上的代码:

Here is my code on the MainMenu:

Private Sub Button1_Click()

Dim txtSearchBar As String
Dim Cancel As Integer

On Error GoTo ErrorBEDSIDSearch

DoCmd.OpenForm "MainForm", , , "SchoolID = " & ("""" & Me.txtSearchBar.Value 
& """"), acFormReadOnly  

Exit Sub

End Sub

这是我在 MainForm 上的代码:

Here is my code on the MainForm:

Private Sub CloseFormOpenMainMenu_Click()

DoCmd.Close
DoCmd.OpenForm "frmMainMenu"

End Sub

如果有帮助,我将Filter On Load"属性设置为No",Filter"属性为空.

If it helps, I have the "Filter On Load" property = No and the "Filter" property is blank.

推荐答案

您可以使用以下代码从其他表单中清除文本框:

You can use the following code to clear the textbox from the other form:

Forms("MainMenu").txtSearchBar.Value = Null

已实施:

Private Sub CloseFormOpenMainMenu_Click()

DoCmd.Close
DoCmd.OpenForm "frmMainMenu"
Forms("MainMenu").txtSearchBar.Value = Null

End Sub

这篇关于关闭表单时如何清除搜索栏文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆