本文介绍了清除新搜索的文本/列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在参与项目的主页,并发现我的重置新搜索命令按钮无法正常工作。应该发生的是,当单击按钮时,将运行事件过程。该事件过程应清除用于搜索查询的文本框,该搜索查询将结果加载到同一表单上的列表框中。


单击时,将在文本框中清除所有内容,列表框已清除,但仅显示第1行中的列分隔线。在输入新的搜索数据之后(让我们说3个方框中的方框2,并且搜索数据在桌子上),搜索数据被输入。点击按钮,列表框完全清除,没有任何显示。


我发现如果我在所有3个文本框中输入内容(比如x,x,x)并点击搜索"没有任何反应,然后返回并删除第一个框,在第二个框中输入有效数据,删除第三个框并单击搜索按钮。再次按下按钮,列表框会在清除第一次搜索后填充。


我可以更改任何文本框值并单击搜索按钮。不使用清除按钮,并在该列表框中加载新行。在新搜索出现问题之前就已经清楚了。


这是清除按钮点击的代码:


Private Sub clearButton_Click()

On Error GoTo Err_clearButton_Click

''清除3个文本框,列表框以便可以进行另一个搜索/查询

Me.WhatLastName。值=""

Me.WhatFirstName.Value =""

Me.WhatMedRecNo.Value =""

Me.SelectPrintItems.RowSource =""

Me.Refresh


Exit_clearButton_Click:

退出Sub


,这里是搜索按钮的代码点击:

Private Sub SearchQuery_Click()

On Error GoTo Err_SearchQuery_Click


''错误检查以确保用户输入姓氏和名字的值。

如果是Nz(Me.WhatLastName,"")& _

Nz(Me.WhatFirstName,"")& _

Nz(Me.WhatMedRecNo,"")=""然后

MsgBox(请输入一个搜索值,所有3可能不是空白)

GoTo Exit_SearchQuery_Click

Else

Me.SelectPrintItems.RowSource =" Lukup_Query"

Me.SelectPrintItems.Requery


结束如果

Exit_SearchQuery_Click :

退出Sub


Lukup_Query只是一个选择,使用WHERE语句中的What ...字段来选择填充列表框。


应该可以工作,但我必须忽略一些明显的东西

I''m on the home streach of my project and found that my "Reset for New Search" command button not working as desired. What should happen is that when the button is clicked a Event Procedure is run. That event procedure should clear the text boxes that are used for a search query that loads the results into a list box on that same form.

When clicked, all is cleared in the text boxes, and the list box is cleared but shows column seperator lines in 1st row only . After entering new search data (let''s say box 2 of the 3 boxes, and the search data is on the table) the "Search" button is clicked, the list box clears completely and nothing showing.

What I discovered is if I enter something in all 3 text boxes (say x, x, x) and click "Search" nothing happens, and then go back and delete 1st box, enter valid data in 2nd, delete 3rd and click the "Search" button again, the list box get populated like it should of after clearning the 1st search.

I can change any of the text box values and click "Search" not using the clear button, and that works loading new rows in that list box. Just the clear before a new search has problems.

Here is the code for the clear button click:

Private Sub clearButton_Click()
On Error GoTo Err_clearButton_Click
'' clear the 3 text boxes, list box so that another search/query can be done
Me.WhatLastName.Value = ""
Me.WhatFirstName.Value = ""
Me.WhatMedRecNo.Value = ""
Me.SelectPrintItems.RowSource = ""
Me.Refresh

Exit_clearButton_Click:
Exit Sub

and here is the code for the search button click:

Private Sub SearchQuery_Click()
On Error GoTo Err_SearchQuery_Click

''Error checking to make sure user entered values for Last Name and First Name.
If Nz(Me.WhatLastName, "") & _
Nz(Me.WhatFirstName, "") & _
Nz(Me.WhatMedRecNo, "") = "" Then
MsgBox ("Please enter a Search value, all 3 may not be blank")
GoTo Exit_SearchQuery_Click
Else
Me.SelectPrintItems.RowSource = "Lukup_Query"
Me.SelectPrintItems.Requery

End If
Exit_SearchQuery_Click:
Exit Sub

The Lukup_Query is just a Select using the What... fields above in a WHERE statement to select for populating the list box.

Should work but I must be overlooking something that is obvious

推荐答案

展开 | 选择 | Wrap | 行号


展开 | 选择 | Wrap | 行号




尝试对刚离开Me.Refresh的文本框执行相同操作

Try doing the same with the text boxes just leaving Me.Refresh


这篇关于清除新搜索的文本/列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 19:10