为什么不能将条件查询的条件指定为表单组件? [英] Why can't I specify criteria for a conditional query as a form component?
问题描述
我有两个下拉菜单,Combo_A和Combo_B. 我正在尝试实现级联组合框"或同步组合框",其中从组合A(例如,美国州)中选择的内容将填充到组合B(例如,属于该州的特定城市列表). /p>
我了解使用VBA代码执行此操作,以及您希望使用VBA的原因,但我的问题是为什么必须使用VBA.
只需执行以下条件的条件查询:
[表格]![主表格]![状态下拉]
似乎不起作用. 在(State_Dropdown的)更新后执行了(City_Dropdown的)重新查询. 然后要求我提供
的值
Form!Main_Form!State_Dropdown
...在操作了State_Dropdown之后.
为什么这不直观? 安全? 功能吗?
假定控件使用相同的表单,则无需引用Forms集合和表单名称.在ComboB RowSource中:
SELECT [City] FROM [Cities] WHERE [State]=[ComboA];
我建议重新查询代码在ComboB GotFocus事件中.
请注意,如果ComboB RowSource包含查找别名,则级联组合框不适用于连续表单或数据表表单.
I have two drop downs, Combo_A and Combo_B. I'm attempting to achieve a "cascading combo box" or "synchronous combo box" where a selection from Combo A (say, a US State) would populate Combo B (say a particular list of cities which belong to said state).
I understand using the VBA code to do this, and the reason you'd prefer to use VBA, but my question is WHY must I use VBA.
Simply making a conditional query with criteria of:
[Forms]![Main_Form]![State_Dropdown]
Doesn't seem to work. There IS a requery (of the City_Dropdown) performed AfterUpdate (of the State_Dropdown). Then I'm asked to provide the values for
Form!Main_Form!State_Dropdown
...after manipulating the State_Dropdown.
Why doesn't this work intuitively? Security? Function?
Assuming the controls are on same form, don't need to reference the Forms collection and form name. In ComboB RowSource:
SELECT [City] FROM [Cities] WHERE [State]=[ComboA];
I recommend the requery code be in ComboB GotFocus event.
Be aware cascading comboboxes don't work nice with continuous or datasheet form if ComboB RowSource includes lookup alias.
这篇关于为什么不能将条件查询的条件指定为表单组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!