简体   繁体   English

MS Access:如何将OpenArgs传递到子窗体中?

[英]MS Access: How to pass OpenArgs into a Subform?

EDIT: nevermind I just created a new form, it looks worse but it's much easier 编辑:没关系,我刚刚创建了一个新表格,它看起来更糟,但是要容易得多

I have a form of orders and there are buttons and a subform on it. 我有一种订单形式,上面有按钮和一个子表单。 The form has a customer name that is given in the OpenArgs property when I open it from the Main form. 当我从Main表单中打开表单时,该表单具有OpenArgs属性中给出的客户名称。 The subform displays the orders that the user(the customer that see the page) did. 子窗体显示用户(查看页面的客户)所做的订单。 When I make a condition that the customer name in the subform equals to the textbox that contains the customer name in the orders form, access 当我确定子窗体中的客户名称等于订单窗体中包含客户名称的文本框的条件时,访问

For example, the customer name is Matthew Jones (Me.OpenArgs="Matthew Jones") http://imageshack.us/photo/my-images/832/accesshelp.jpg/ 例如,客户名称为Matthew Jones(Me.OpenArgs =“ Matthew Jones”) http://imageshack.us/photo/my-images/832/accesshelp.jpg/

Thank you and sorry if I had grammer mistakes 谢谢你,如果我有语法错误,对不起

I'm not sure if I understand what your actual question is. 我不确定我是否理解您的实际问题。
This sentence looks like you posted the question without completing the sentence: 这句话看起来像您在未完成句子的情况下发布了问题:

When I make a condition that the customer name in the subform equals to the textbox that contains the customer name in the orders form, access 当我确定子窗体中的客户名称等于订单窗体中包含客户名称的文本框的条件时,访问

If your question is how to get this to work, the solution is to write the query in the subform like this: 如果您的问题是如何使它起作用,解决方案是将查询写在子窗体中,如下所示:

select *
from orders
where customer=[Forms]![OrderForm]![TextboxWithCustomerName]

You don't need to pass information to the subform via OpenArgs, because the subform is aware of the content of its parent form. 您不需要通过OpenArgs将信息传递给子表单,因为子表单知道其父表单的内容。 You can access any data in the subform's parent form with Me.Parent. 您可以使用Me.Parent访问子窗体的父窗体中的任何数据。 So, in the subform, if you wanted the CustomerName displayed in the parent form to be used in the subform, you'd use: 因此,在子表单中,如果您希望在父表单中显示的CustomerName可以在子表单中使用,则可以使用:

  Me.Parent!CustomerName

Keep in mind that you need to be sure that if CustomerName is a field in the parent form's Recordsource, it will be reliably accessible only if it's used as the ControlSource of a control on the parent form. 请记住,您需要确保,如果CustomerName是父窗体的Recordsource中的一个字段,则只有当它用作父窗体上控件的ControlSource时,才能可靠地访问它。

You can use the LinkChildFields, LinkMasterFields properties of the subform control 您可以使用子窗体控件的LinkChildFields,LinkMasterFields属性

  • In LinkMasterFields you must write 在LinkMasterFields中,您必须编写
    the control name containing, in this case the customer's name. 控件名称,在这种情况下包含客户的名称。
  • In LinkChildFields you must write the field name of the orders list containing the customer's name. 在LinkChildFields中,您必须输入包含客户名称的订单列表的字段名称。

The subform control makes the join between the 2 forms (main and child forms) and filter the subform acording the content of the main form. 子窗体控件在2个窗体(主窗体和子窗体)之间进行联接,并根据主窗体的内容过滤子窗体。

Note that "subform control" is the container of the child form. 请注意,“子窗体控件”是子窗体的容器。 The child form is a normal form that is loaded by a special control: the subform control. 子窗体是由特殊控件(子窗体控件)加载的普通窗体。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM