Subforming a request from another subform, problems

I have 2 subforms on the main form. Sub_2 displays the details for the item selected in sub_1 in the list. For both subforms, a continuation form is used, and they are limited to two queries, with one common field, for example, "id".

What I did was add the code to the DClick event on sub_1 to set the sub_2 filter, for example

Me.Parent.sub_2.Form.Filter = "id=" & "'" & Me.Recordset!id & "'" 

Then request

 Me.Parent.sub_2.Form.Requery 

But no luck when I double-clicked the entry in sub_1, no change to sub_2. I looked at the relevant questions, I think this should work ...

Any suggestions? Maybe I should use a different approach for this?

PS: I'm sure Me.Parent.sub_2.Filter changed, but requery is not working.

EDIT:

Thanks for answers. I find the problem, that is, the "id" field is in the request, but it does not appear in the subform, so Access may not be able to use it.

And when you change the filter, Access automatically executes the request.

+4
source share
3 answers

You do not need to do anything with the filter property.

In the first subform, set the Link Master Fields and Link Child Fields properties in the same way as for the regular single subform control.

For the second subform, also set the Link Child Fields property, as well as for the usual single slave control. The Link Master Fields property will refer to the control name of the first subform: [Subform 1 Control Name]! NameName

In the OnCurrent event for the first subform control, add the following line of VBA code:

 Me.Parent.Controls![Subform 2 Control Name].Requery 

Run the form. When you click a row in the first subform, the second subform will ask for the display of the child rows for the row selected in the first subform.

+4
source

Set the FilterOn property to True after assigning the Filter expression.

 Me.Parent.sub_2.Form.Filter = "id=" & "'" & Me.Recordset!id & "'" Me.Parent.sub_2.Form.FilterOn = True 
+2
source

You will need something like the following:

 Me!Subform2.Form.Requery 'or Forms!Mainform!Subform1.Form!Subform2.Form.Requery 

I did not have time to check this, so I can not say for sure whether Subform1 and Subform2 will be the name of the actual subform or just a Subform element / container. I think this is the last.

Here's a great source for questions like:
http://access.mvps.org/access/forms/frm0031.htm

My only complaint on this page is that they do not cover calling methods, subs / functions or referring to public variables. All of them (or maybe) are slightly different from the scenarios listed there.

0
source

All Articles