子窗体Combobox自动填充另一个子窗体文本框 [英] Subform Combobox Autofill Another Subform Textbox

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

问题描述

你好,伙计们。这是我的第一篇文章,我在3周前才开始广泛使用Access。我在Windows XP上运行Access 2003.


我想在子表单2中使用一个文本框来反映从子表单1中的组合框中选择的值。仅供参考:这两个子表单都链接到具有五个字段的主表单(自动编号,数量,资源,类型和一般说明;自动编号是主键)。


我的主表单列出了一个资源(例如计算机),主表单中的一系列选项卡包含有关它的信息。每个选项卡都包含一个子表单。第一个选项卡(名为管理)是前进选项卡的摘要。它有一个名为Purchase Request by的组合框。我拉下这个组合框并选择Jane Doe。第二个选项卡称为购买请求。相应地,存在标记为Purchase Request by的文本框。我想用Jane Doe自动填充基于我对管理的选择。


我知道这不是很大的困难,但我已经用尽了我的搜索功能,主要找到了连接这些的例子同一表单中的两种类型的输入相同(不是从子表单到选项卡中的子表单)。我将不胜感激任何帮助和简单的指示。每当我遇到没有基本指令的简单VB或SQL响应时,我都会迷失,因为我不知道这些语言和/或如何使用Access实现它们。一个明确的解释真的非常有用。


提前致谢,

Benny

Hello, folks. This is my first post and I only began to work extensively with Access about 3 weeks ago. I''m running Access 2003 on Windows XP.

I''d like a textbox in subform2 to reflect the value chosen from a combobox in subform1. FYI: Both of these subforms are linked to a main form with five fields (AutoNumber, Quantity, Resource, Type, and General Description; "AutoNumber" is the primary key).

My main form lists a resource (e.g. computer) and a series of tabs within the main form contain information about it. Each tab contains a subform. The first tab (named "Administration") is a summary of the proceeding tabs. It has a combobox called "Purchase Request by." I pull down this combobox and select "Jane Doe." The second tab is called "Purchase Request." Correspondingly, there is a textbox labeled "Purchase Request by" that I want to autofill with "Jane Doe" based on my selection from "Administration."

I know this isn''t cosmically difficult, but I''ve exhausted my search capabilities and mainly have found examples of linking these same two types of inputs within the same form (not from subform to subform within tabs). I would appreciate any help and simple instructions. Whenever I come across simple VB or SQL responses without basic instruction, I get lost because I don''t know those languages and/or how to implement them using Access. A clear explanation would really, really help.

Thanks in advance,
Benny

推荐答案


你好,伙计们。这是我的第一篇文章,我在3周前才开始广泛使用Access。我在Windows XP上运行Access 2003.


我想在子表单2中使用一个文本框来反映从子表单1中的组合框中选择的值。仅供参考:这两个子表单都链接到具有五个字段的主表单(自动编号,数量,资源,类型和一般说明;自动编号是主键)。


我的主表单列出了一个资源(例如计算机),主表单中的一系列选项卡包含有关它的信息。每个选项卡都包含一个子表单。第一个选项卡(名为管理)是前进选项卡的摘要。它有一个名为Purchase Request by的组合框。我拉下这个组合框并选择Jane Doe。第二个选项卡称为购买请求。相应地,存在标记为Purchase Request by的文本框。我想用Jane Doe自动填充基于我对管理的选择。


我知道这不是很大的困难,但我已经用尽了我的搜索功能,主要找到了连接这些的例子同一表单中的两种类型的输入相同(不是从子表单到选项卡中的子表单)。我将不胜感激任何帮助和简单的指示。每当我遇到没有基本指令的简单VB或SQL响应时,我都会迷失,因为我不知道这些语言和/或如何使用Access实现它们。一个明确的解释真的非常有用。


提前致谢,

Benny
Hello, folks. This is my first post and I only began to work extensively with Access about 3 weeks ago. I''m running Access 2003 on Windows XP.

I''d like a textbox in subform2 to reflect the value chosen from a combobox in subform1. FYI: Both of these subforms are linked to a main form with five fields (AutoNumber, Quantity, Resource, Type, and General Description; "AutoNumber" is the primary key).

My main form lists a resource (e.g. computer) and a series of tabs within the main form contain information about it. Each tab contains a subform. The first tab (named "Administration") is a summary of the proceeding tabs. It has a combobox called "Purchase Request by." I pull down this combobox and select "Jane Doe." The second tab is called "Purchase Request." Correspondingly, there is a textbox labeled "Purchase Request by" that I want to autofill with "Jane Doe" based on my selection from "Administration."

I know this isn''t cosmically difficult, but I''ve exhausted my search capabilities and mainly have found examples of linking these same two types of inputs within the same form (not from subform to subform within tabs). I would appreciate any help and simple instructions. Whenever I come across simple VB or SQL responses without basic instruction, I get lost because I don''t know those languages and/or how to implement them using Access. A clear explanation would really, really help.

Thanks in advance,
Benny



Benny,


虽然可能很难将两个子表单相互链接,但将它们链接到主表单上的字段相当简单。


例如:您可以在主窗体上设置一个对最终用户不可见的文本框。此文本框将引用(等于)subform1中的值。然后,您可以将子窗体2设置为引用(等于)主窗体上的文本框。输入数据后,您可能需要设置一些事件来刷新表单,但它应该可以工作。

Benny,

While it may be difficult to link the two subforms to each other it is fairly simple to link them to a field on the main form.

For example: You could set up a textbox on the main form that is not visible to the end user. This textbox would reference (equal) the value from subform1. Then you could set your subform2 to reference (equal) the textbox on the main form. You might need to set up some events to refresh your form after you enter data, but it should work.



例如:你可以在主窗体上设置一个对最终用户不可见的文本框。此文本框将引用(等于)subform1中的值。然后,您可以将子窗体2设置为引用(等于)主窗体上的文本框。输入数据后,您可能需要设置一些事件来刷新表单,但它应该可以正常工作。
For example: You could set up a textbox on the main form that is not visible to the end user. This textbox would reference (equal) the value from subform1. Then you could set your subform2 to reference (equal) the textbox on the main form. You might need to set up some events to refresh your form after you enter data, but it should work.



卢克,

感谢您的回复。我已经有一段时间接受了这个想法,因为链接到主要表单很容易。但是,大约有8个选项卡,每个选项卡都有自己的子窗体,控件最终会从第一个选项卡的子窗体中提取信息。所以,使用你的建议,这意味着我必须在主窗体上放置8个不同的隐藏控件,让它们将各自的数据显示在每个子窗体中。虽然我不喜欢弄乱我的主要形式(当然只有在设计模式下),如果我找不到另一种解决方案,我将不得不放手一搏。


我试图让文本框只是查询subform1表中的信息,但是我做错了和/或它不起作用。如果我做一个简单的查询,其中字段是PurchaseRequestby并且该表是tblAdminTab,我的文本框(链接时)应该从subform1的组合框中提取信息似乎是合乎逻辑的,但事实并非如此。文本框保持空白。 (实际上,我甚至没有在文本框的属性中看到行源类型或行源字段,所以我不确定我是否尝试链接文本框。)但是,如果我制作文本框是一个组合框并将相同的查询链接到它,组合框确实显示结果。不好的是它显示了已输入PurchaseRequestby的所有记录。列而不仅仅是所需的选定/当前值。而且,最重要的是,我仍然希望组合框成为一个文本框。


还有什么进一步的想法吗?

Hi, Luke,

Thanks for your reply. I''ve entertained this idea for a while because linking to the main form is easy. However, there are about 8 tabs each with their own subform with controls that''ll eventually draw information from the first tab''s subform. So, using your suggestion, this would mean that I''d have to put 8 distinct hidden controls on the main form to have them display their respective data into each subform. While I''m not a fan of cluttering up my main form (only in design mode, of course), I''ll have to give this a go if I can''t find another solution.

I tried to have the textbox simply query the information from subform1''s table, but I''m either doing it wrong and/or it doesn''t work. If I make a simple query where the field is "PurchaseRequestby" and the table is "tblAdminTab," it seems logical that my textbox (when linked) should draw the information from subform1''s combobox, but it doesn''t. The textbox just remains blank. (Actually, I don''t even see "Row Source Type" or "Row Source" fields in the properties for the textbox, so I''m not sure I even attempted linking the textbox.) However, if I make the textbox a combobox and link this same query to it, the combobox does display results. The bad thing is that it shows ALL records that have been input into the "PurchaseRequestby" column instead of just the desired selected/current value. And, most importantly, I still want the combobox to be a textbox.

Any further thoughts?


可能是最简单的避免任何方法的方法隐藏文本框只是让第一个选项卡中的其他选项卡引用字段。假设我有以下内容:


一个名为:订单详细信息的表单

一个包含子表单的选项卡,名为:"该选项卡上的订单详细信息子表单

是一个不同的子表单,名为:订单子表单

订单详细信息子表单中有一个字段。称为ProductID


为了在第二个子表单上引用该字段,我将创建一个文本框并将其控件源设置为= Forms![Order and Details]! [订单详细信息子表单.Form![ProductID]"


唯一的问题是如果你在第二个子表单中使用它(如你所描述的那样)那么第二个子表单中的每个记录都将保留此值。如果那就是你想要的那么你就是好的!


希望这会有所帮助!


~Luke
Probably the most simple approach that avoids any hidden textboxes is to just have the other tabs reference field from the first tab. Let''s say I have the following:

A Form called: "Order Details"
A tab with a subform on it called: "Order Details Subform"
on that tab is a different subform called: "Orders Subform"
There is a field on "Order Details Subform" called "ProductID"

In order to reference that field on the second subform, I would create a textbox and set its control source to "= Forms![Order and Details]![Order Details Subform].Form![ProductID] "

The only problem with this is that if you are using this in a second subform (like you''ve described) then every record in the second subform will hold this value. If that''s what you want then you''re good!

Hope this helps!

~Luke


这篇关于子窗体Combobox自动填充另一个子窗体文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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