link Child/Master fields with Separate subform

buratti

Registered User.
Local time
Today, 12:52
Joined
Jul 8, 2009
Messages
234
I have a main form that has 2 separate subforms (NOT to be confused with a subform with another subform INSIDE that one). Lets call them Subform1 and Subform2 for ease of explanation right here. What I need is to link a child field of [MenuID] in subform2 with a Master Field of [MenuID] in Subform1

So the end result would be for example... I open the main form and select a record in subform1. Let’s say the value of MenuID of that record is 1. I need all records in subform2 to be displayed with a MenuID value of 1 also. Just as if Subform2 were actually inside subform1. But before anyone suggests to just do that, subform1 needs to be in continuous form view, and I cannot add a subform to the detail section when in that view(also placing the subform in the footer would technically work, but would not allow me to get the "visual" display I was hoping for).

This is what I have come up with so far but cannot get it to work, or don't even know if this is the right way to go about this:

In the on Current event of subform1 I put:
With Me.Parent.Subform2.Form
.LinkChildFields = Me.Parent.Subform2.Form.MenuID
.LinkMasterFields = Me.MenuID

End With

But have no luck. Does anybody have any suggestions on how to get this to work?
 
the way to do this is to base subform2 on a query that takes into account the current item in subform1

then the current event for subform1 needs to have code

subform2.requery

the only catch is a possible situation where there is no item in subform1, in which case, the current event doesnt fire.
 
the way to do this is to base subform2 on a query that takes into account the current item in subform1

I'm sorry, I should know how to do this, but having a brain fart right now. I am such a quick learner when it comes to Access and coding, but also forget the simplest things quickly when I dont use it for a while, and I haven't designed anything in Access in a month or so. Could you give me a hint or point me in the right direction, so it will come back to me?

the only catch is a possible situation where there is no item in subform1, in which case, the current event doesnt fire
.
This shouldn't be a problem because if sub1 has not records then sub2 wouldn't either.
 
Here's how:

1. Drop a textbox onto the main form and set it's control source to the MenuID field of subform1. Let's say the textbox was called txtMenuIDLink
2. In the Link Master Fields property of subform 2, type in txtMenuIDLink. Don't click the elipsis button because you will not find that name there.
3. Type the Link Child Fields property as well and you're done.
 

Users who are viewing this thread

Back
Top Bottom