Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking Unbound Subforms

Status
Not open for further replies.

JDU

Technical User
Dec 23, 2002
182
US
Is there any way to link Unbound subforms so that when a record appears in one unbound subform the corresponding record appears in the other unbound subform. Thanks
 
Hello JDU,
In the
Code:
On Current
event of subform A, add the following code:
Code:
Forms![Name of subform B].Form.Recordset.FindFirst "ID = " & Me.Form.Recordset!ID
You will have to replace "ID" with the actual name of the primary/foreign keys.

On problem with this method is that it will only work when you make changes to subform A. If you add the same code to subform B, you may cause an error -- I haven't tested this code.

If you absolutely needed two subforms to be bound to eachother, but not the main form, I would probably do the following:
In the main form, add a subform. Within that subform add the two subforms and link them to the subform that is just below the main form.

So, you would have a hierarchy like this:
Code:
           Main Form
                |
             Subform A
             |      |
       Subform B  Subform C
This would allow you navigate through the subform records, using Subform A. Hope that was clear.
Good Luck, Robert
•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•
Professional, affordable, Access database solutions and assistance °•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°
 
I tried the above code, but I keep getting the error 2450, that it can't find the subform referenced. I troubleshot the spelling etc. I even recreated the subform and the same error prevailed.

I don't know what you mean by the latter suggestion. I don't how to create subforms within subforms. Please clarify and Thanks so much for your help.
 
Hello again,
Ok... some fundamental questions that I need to ask:

1) Why are the subforms not linked to the main form? If the data in the subforms is not related, why is it there? Please note that it is not incorrect to do this, I am just trying to get a clear picture of what you are doing.

2) What do the subforms have in common with eachother that makes synchronizing their records so important? I am refering to similarities in the function that they serve.

3) Adding to question 2, would it be possible [logical] to combine the two subforms together so that you would only have one subform?

Thank you, Robert
•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•
Professional, affordable, Access database solutions and assistance °•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°
 
Ok, this is relatively simple to do...

On the parent form add an invisble text box, we will name it "LinkBox" for this example.

On your first subform, create some code for the OnCurrent event of the form.

me.parent("LinkBox")=[FieldName]

Now simply bind the Parent link of the second subform to LinkBox, and the Child field to FieldName (whatever field it may be).

Its as simple as that.
 
Answer 1,2: I have an unbound form with two unbound subforms; one shows the date, title, employeeID, employee name and vacation date requested. The other one shows employeeID, employee name, and what dept the database assigned them to work on the day that they requested off. I wanted the user to be able to see both of these pieces of info which reside in two seperate locations (a query and a table) on a single form, thus the two unbound subforms on a single form. Based on this they would use the combo boxes on the FORM to invoke another query with the info they got from the 2 subforms.

Answer 3: I am willing to try but have not done this before.
 
That did it. Thanks Fubear. Also Thanks for your help SoloDroid.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top