开发者

MS Access: How to pass OpenArgs into a Subform?

开发者 https://www.devze.com 2023-03-15 11:00 出处:网络
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.

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. The subform displays the orders that the user(the customer that see the page) did. When I make a condition that the customer na开发者_JAVA技巧me 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/

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. You can access any data in the subform's parent form with 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:

  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.


You can use the LinkChildFields, LinkMasterFields properties of the subform control

  • In LinkMasterFields you must write
    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.

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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号