Combobox停止自动填充所选项目的文本部分 [英] Combobox Stop Autofilling Text portion from selected item

查看:67
本文介绍了Combobox停止自动填充所选项目的文本部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我的数据输入表格上有一个组合框。当用户键入时,表单的列表部分会自动刷新以显示包含该文本的项目。但是,当用户然后使用箭头键选择项目时,它会自动更新文本区域。这不利于我的目的,因为它不允许用户在顶部选项之外的列表框部分中选择项目。有没有办法防止这种情况发生?


我将在下面发布我的代码,以便自动刷新组合框以查看问题是否在那里,但我不是认为它与此有关。

Hi all,

I have a combobox on my data entry form. When a user types, the list section of the form auto-refreshes to display items containing the text. However, when a user then selects an item using the arrow keys, it automatically updates the text region. This isn''t good for my purpose as it doesn''t allow users to select items in the list box section beyond the top option. Is there a way to prevent this from happening?

I will post my code below for the auto-refreshing of the combobox to see if the problem lies in there but I don''t think it''s related to that.

展开 | 选择 | Wrap | 行号

推荐答案

David,


请更好地解释一下:
David,

please explain this a little bit better:

当用户输入时,表单的列表部分会自动刷新以显示包含文本的项目。但是,当用户然后使用箭头键选择项目时,它会自动更新文本区域。这不利于我的目的,因为它不允许用户在顶部选项之外的列表框部分中选择项目。
When a user types, the list section of the form auto-refreshes to display items containing the text. However, when a user then selects an item using the arrow keys, it automatically updates the text region. This isn''t good for my purpose as it doesn''t allow users to select items in the list box section beyond the top option.



我不确定我明白发生了什么。什么是

I''m not sure I understand what is happening. What is meant by


它会自动更新文本区域
it automatically updates the text region






另外,是cmdLocationID你的组合盒?它被命名为命令按钮,这对我来说非常混乱(以及将来可能需要对数据库进行故障排除/修改的任何其他人)。您还可以在代码中将其称为列表框。最好将其命名为cboLocationID。


但是,我对你的代码本身更加困惑。显然,在用户更改组合框的值后,您可以根据组合框的选择重置组合框中的项目列表???????


无论如何,代码的第15-33行完全没必要,事实上你的代码可能会大大减少。我建议更改代码以反映构建查询,然后简单地将该查询指定为组合框的行源:

?

Additionally, is "cmdLocationID" your Combo Box? It is named as a Command Button, which is very confusing to me (as well as anyone else who might have to troubleshoot/modify your database in the future). You also refer to it in your code as a "List Box". It might better be named "cboLocationID".

However, I am even more thoroughly confused by your code itself. Apparently, after a user changes the value of the combo box, you then reset the list of items in the combo box based on the selection of the combo box???????

Regardless, lines 15-33 of your code are completely unnecessary, and in fact your code might be cut down significantly. I would recommend changing your code to reflect building a query and then simply assigning that query as the Row Source for your Combo Box:

展开 | 选择 | 换行 | 行号


组合框有一个位置列表,因此当用户键入时,选项列表应该只包含包含用户键入的字符串的位置。


当用户按下向下箭头时,它会选择列表部分中的第一个选项,然后将文本框区域中的文本更新为与列表框p相同ortion然后更新列表框...基本上没有按预期工作。


例如目前正在发生


在文本部分输入新内容 - >过滤结果到New Amsterdam,New England,New York - >用户按下箭头想要选择新英格兰 - >组合框立即将文本部分更新为新阿姆斯特丹,因为这是所选择的选项 - >列表框更新只包含新阿姆斯特丹


我需要发生的事情:


在文本部分输入新内容 - >过滤结果到New Amsterdam,New England,New York - >用户按下箭头想要选择新英格兰 - >文本框只是说新的,所以列表框部分不被重新查询 - >用户突出显示新英格兰并按下输入 - >干完了!


为什么我叫它cmd而不是cbo ...这是任何人的猜测!


我试过实现新代码,行源只是空白,没有选项。我想我可能做错了什么!


查询的SQL是:

The combo box has a list of locations, so when the user types, the list of options should only contain the locations which contain the string that the user has typed.

When the user pressed the down arrow, it selects the first option in the list portion, then updates the text in the textbox region as the same as the listbox portion and then updates the listbox... essentially not working as expected.

e.g. currently happening

Typing New in text portion -> filters results to New Amsterdam, New England, New York -> user presses down arrow wanting to select New England -> the combobox immediately updates the text portion to New Amsterdam as this is the selected option -> list box updates to contain just New Amsterdam

what i need to happen:

Typing New in text portion -> filters results to New Amsterdam, New England, New York -> user presses down arrow wanting to select New England -> textbox stays just saying New so the listbox part isn''t requeried -> user highlights New England and presses enter -> job done!

Why I called it cmd rather than cbo... that is anyone''s guess!

I have tried to implement your new code, the row source is just blank and has no options. I guess I have probably done something wrong!

The SQL for the query is:

展开 | 选择 | Wrap | 行号


首先,我将组合框行源类型更改为表/查询并确保(我认为这是导致错误 - 我不确定.Requery是否需要这个案例)。


然后,在这种情况下,我建议为搜索字段使用单独的文本框。然后,在文本框的AfterUpdate事件中:

First, I would change the Combo Box Row Source Type to Table/Query and make sure (I think that was causing the error--and I''m not sure the .Requery is required in this case).

Then, in this case, I would recommend using a separate text box for a search field. Then, in the Text Box''s AfterUpdate event:

展开 | 选择 | Wrap | 行号


这篇关于Combobox停止自动填充所选项目的文本部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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