Full Version: Getting a 'linked' value in a subform
UtterAccess Forums > Microsoft® Access > Access Forms
WynApse
Modifying some legacy code I inherited as usual, and thought this would be simple :(
I have a form with a subform, let's call it ChildrenSubForm. In the ChildrenSubForm, there is a Detail section tied to a table of children. The child's name is displayed, and then in the footer is the birthdate. So as a child is selected, the birthdate follows as expected.
This isn't actually what this IS, but the concept works for explanation, and because of this, we'll assume that somehow the kids names and birthdays are entered and just appear here.
Then at the bottom of that subform is a GrandChildrenSubForm.
The GrandChildrenSubForm is linked to the ChildrenSubForm by the Child's Name and ID, which are part of the record used to display the birthdate.
There is a Detail of the GrandChildren in the GrandChildrenSubForm. When a Child is selected in the parent subform, the Grandchildren are then displayed from another table in it's subform by using the Child's Name and ID.
What I'd like to do is display the Child's name in the Detail as a static piece of text that just gets displayed next to the Grandchildren info.
At any given time, there is only one valid Child that the subform is using, and it's linked to it's parent by that value, but I can't figure out how to get my hands on it to display it.
I hope this makes sense... I tried to make it mirror what I'm doing and leave out extraneous stuff...
Thanks!
-Dave
theDBguy
When you said that the GrandChildrenSubForm is linked to the ChildrenSubForm by the Child's Name and ID, does that mean that the Child's Name is available in the record source of the GrandChildrenSubFrom? If so, why not just use that field to display the Child's Name?
Hope that helps...
WynApse
Actually, I meant the Child's name was listed as a Master Field and Child Field in the "Subform Field Linker"
Thanks!
-Dave
theDBguy
Ok, when you said "Child Field," is that not the name of the child?
WynApse
Yes it is...
But my question is... I have a link between the parent and child forms using the "Subform Field Linker" that identifies a field in the parent record... is there no way to get access to that directly by name?
theDBguy
I'm sorry. I guess I am not getting your question (and sometimes it could be because posters use hypothetical situations instead of the actual problems). What value did you want to display: the child's name (Joe, John, etc), or the field name that was used for the link ([ChildName], [ChildID], etc)?
WynApse
Well... sorry about that, but I can't post the actual problem because I work in a secure area, not to mention the mdb is 17M and all the tables are linked out to Oracle.
here's this box called the "Subform Field Linker" ... in it I tell it I want it to link the parent form and the subform via 2 items:
ChildID, ChildName ..... yeah I know it would appear I only need the ID, this is part of the whole if I told you I'd have to kill you part, so let's just let that go.
So I select "Alice" in the main form ... let's say "Alice" is ChildID 1
So now the parent and child are linked by:
ChildID=1
ChildName='Alice'
Alice's children appear in the subform, and I'd like to display the text "Alice" on the subform somewhere, but I don't want to get it from the record being used in the subform, I'd like to get it from the linkage between the two forms... see above where ChildID=1 and ChildName='Alice' .... is it possible to get access to the name 'Alice' in this case directly?
theDBguy
This shouldn't be so hard, it just seems that way because we're both talking from different views (you from knowing what the forms/db look like, and me from guessing what they look like).
If the subform is linked by ChildName (as well as ChildID), then I would hope that the value of ChildName (like Alice) is available to both the main and the subform. If so, just use the one in the subform to display it in the subform.
For example, when you display the "Field List" window when in the Design View of the subform, do you see the field "ChildName?" If so, just drag that field onto the Detail section of the subform and it should display "Alice" when "Alice" is selected from the main form.
Hope that helps...
WynApse
OK thDBguy...
That was actually not how I was expecting to do this, but was simple to the point I had ignored it during the other 50 attempts.
Now that it works, it makes sense.... I had been conditioned by the goofy way my predecessor had drop-down boxes for EVERYTHING.
Thanks for the assist and sorry it took so long to pull my head out..
-Dave
theDBguy
You're welcome. I'm glad you finally got it figured out. Good luck with your project.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.