从父窗体中选择的值填充子窗体中的列表框 [英] To populate listbox in subform from value selected in parent form

查看:62
本文介绍了从父窗体中选择的值填充子窗体中的列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从父表单列表框(列表1)中选择的值填充子表单中的列表框(列表2)?


我可以放入行列表的来源2一个查询将表'的字段与列表1.value匹配,但我不知道如何将此值从父表单传递到子表单,并且我应该填充列表2的行源。


感谢您的任何提示。

How can I populate the list box (list 2) in subform from a value selected in a list box (list 1) in parent form?

I can put in the row source of list 2 a query to match a table''s field to the list 1.value, but I don''t know how to pass this value from parent form to subform and where I should populate the row source of list 2.

Thanks for any tips.

推荐答案

参见参考子表单上的项目,然后考虑在问题中包含更多信息以获取更详细的帮助。我甚至不确定你的问题究竟是什么。
See Referring to Items on a Sub-Form for that bit and then consider including more information in the question for more detailed help. I''m not even sure from your question what you''re after exactly.


说我有父表单:FormA有一个列表框:lst1,它有几行说显示人名。

当选择此列表中的一行时,它应填充一个列表框:子窗体上的lst2:FormB,带有相关数据,说明所选人员的子项。

我实际把子窗体放在FormA的页面上,比如PageA1。


我想我应该使用查询来填充lst2.rowsource,选择子窗口= lst1.value。


我认为lst2.rowsource中查询的语法是:
Say I have the parent form: FormA that has a listbox: lst1 and it has a few rows say displaying people''s names.
When a row in this list is selected, it should populate a listbox: lst2 on the subform: FormB, with relevant data, say the selected person''s children.
I put the subform on a page of FormA actually, say PageA1.

I suppose I should populate lst2.rowsource with query that selects the children where parent = lst1.value.

I suppose the syntax of the query in lst2.rowsource is:
展开 | 选择 | Wrap | 行号


这是一个更清晰的工作:-)


我现在的问题是,在试图解释你已经找到了相当好的答案你提出的一切。再好。


您可能希望了解另一种方法。在用于lst2的RowSource的SQL中,您可以在FormA.lst1的 AfterUpdate 事件过程中使用代码中内置的字符串文字。然后,如果lst1的值是Murphy,你最终会得到类似的东西:

That''s a much clearer job :-)

My problem now is that in attempting to explain you have found correct answers to pretty well everything you asked. Good again.

There is an alternative approach that you may wish to be aware of though. In the SQL used for the RowSource of lst2 you could use a string literal built within your code in the AfterUpdate event procedure of FormA.lst1. Then, if the Value of lst1 were "Murphy", you would end up with something like :

展开 | 选择 | 换行 | 行号


这篇关于从父窗体中选择的值填充子窗体中的列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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