填充组合框 [英] Populate combobox

查看:83
本文介绍了填充组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助...我想在表单上填充一个组合框,其中包含

查询,用于比较两个表中的数据。

table1中唯一的记录应该继续填充我的组合框。记录

也出现在table2中的那一刻它不再列在我的组合框中。

这不是任何一个表中的关键字段。基本上我想要做的就是阻止用户输入重复的值,即使它不是一个关键字段。我试图通过在组合框中限制他们的

选项来做到这一点。有一个合理的原因是没有

字段作为密钥。


感谢您的帮助

解决方案

你可以通过插入这个SQL作为组合框的'RowSource

值来实现。


SELECT Tabl1.Field1

FROM Table1 LEFT JOIN Table2

ON Table1.Field1 = Table2.Field1

WHERE(((Table2.Field1)Null ));


你还需要将组合框的RowSourceType设置为Table / Query。


如果你想要在向Table2中绑定的

列添加新值时更新RowSource,您需要为

适用控件添加AfterUpdate事件以调用Requery方法对于那个控制。


2006年1月21日20:20:12 -0800,Jamey < CA ********* @ yahoo.com>写道:

你可以通过插入这个SQL作为组合框的'RowSource
值来实现。

SELECT Tabl1.Field1
FROM Table1 LEFT JOIN Table2
ON Table1.Field1 = Table2.Field1
WHERE(((Table2.Field1)为空));

你还需要将组合框的RowSourceType设置为Table / Query。

如果要在Table2的绑定
列中添加新值时更新RowSource,则需要为
适用的控件添加一个AfterUpdate事件,以调用该控件的Requery方法。



在这种情况下,我通常会在Enter事件中重新查询组合。


Sub MyCombo_Enter()

Me.MyCombo.Requery

End Sub


这确保了组合的行数总是最新的,而不需要依赖其他控件。


Wayne Gillespie

澳大利亚戈斯福德澳大利亚


好点。这也减少了组合获得
requeried的次数。


Help Please... I would like to populate a combo box on a form with a
query that compares data from two tables. Any record that is unique in
table1 should continue to populate my combobox. The instant the record
appears also in table2 it should no longer be listed in my combo box.
This is not a key field in either of the tables. Basically what I am
trying to do is prevent the user from entering duplicate values even
though it is not a key field. I am trying to do this by limiting their
choices in the combo box. There is a legitimate reason for neither
field being a key.

Thanks for your help

解决方案

You can do that by inserting this SQL as the combo box''s RowSource
value.

SELECT Tabl1.Field1
FROM Table1 LEFT JOIN Table2
ON Table1.Field1 = Table2.Field1
WHERE (((Table2.Field1) Is Null));

You''ll also need to set the combo box''s RowSourceType to Table/Query.

If you want to update the RowSource as you add new values to the bound
columns from Table2 you''ll need to add an AfterUpdate event for the
applicable control to call the Requery method for that control.


On 21 Jan 2006 20:20:12 -0800, "Jamey" <ca*********@yahoo.com> wrote:

You can do that by inserting this SQL as the combo box''s RowSource
value.

SELECT Tabl1.Field1
FROM Table1 LEFT JOIN Table2
ON Table1.Field1 = Table2.Field1
WHERE (((Table2.Field1) Is Null));

You''ll also need to set the combo box''s RowSourceType to Table/Query.

If you want to update the RowSource as you add new values to the bound
columns from Table2 you''ll need to add an AfterUpdate event for the
applicable control to call the Requery method for that control.



In this situation I normally requery the combo in the Enter event.

Sub MyCombo_Enter()
Me.MyCombo.Requery
End Sub

This ensures the the combo''s rowsource is always current without the need to rely on other controls.

Wayne Gillespie
Gosford NSW Australia


Good point. That also cuts down the number of times that the combo gets
requeried.


这篇关于填充组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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