Link to home
Start Free TrialLog in
Avatar of Sara Hedtler
Sara Hedtler

asked on

One To Many Relationships

Forgive me; but I'm extremely new to Access.  I've created a Table "T-Customer" and have the Key as "CustomerID" and have created a table called "Inventory" with an "InventoryID".  From these tables, I've created a Query with a One-To-Many relationship "One" Customer to "Many" Inventory and then have created a Master Form with Customers and a Subdatasheet with Inventory.  When I click on "Add Inventory", a child form pops up- but doesn't automatically populate the "CustomerID" in the Child Form.  I just need to know how to make this happen and I'm afraid I'm overthinking it...
Avatar of Kelvin Sparks
Kelvin Sparks
Flag of New Zealand image

Have you set the parent and child properties of the subform (on the data property tab)?
This should manage it for you.


Kelvin
Normally you wouldn't display the parent ID, and just Access manage this in the background
Avatar of Sara Hedtler
Sara Hedtler

ASKER

I apologize Kevin, but I'm not quite sure what you mean?
The inventory form actually is an actual policy list; hard to explain- but each is different.  So I gave them Keys as they may have to be edited.
OK, I may have misunderstood how you've designed your forms - using subdatasets (which I have never used) rather than subforms. With a subform, you define the parent/child relationship so that the sunform inherits the ID of the parent form automatically. This is a property of the subform (I assume that a subdataset also has properties). Once this is set, Acess will manage that for you.


Kelvin
Probably no real way to understand my madness!  The main form does have a subform that outlines the "Jist" of the other form.  Is there a way I can send it to you?  I'm sure if you could see it, it would make sense.
You should be able to upload it here
I just sent it via email on here.
Replied, although you should always post examples etc here rather than as a message to an individual
I've attached a slimmed down version.  PLEASE remember, I'm so new to this.  I'm sure I've made some errors.
ACCESS-PROJECT.accdb
Looking at F_ClientSetup, you've correctly set the Parent Child.
Did you try closing and reopening to see if the ClientID was populated afterward. I don't think it is, until Access saves the record (after you move off it - or close the form.

Kelvin
Generally, you wouldn't add this column onto the form - there's no point in seeing it (other than to add to your anxiety). You will know it from the parent (if you need it at all). I prefer to leave it off, or at least make it non visible so as not to confuse people.


Kelvin
I did?  YAY!!!  I did close out of the form, closed out of access and then went back in and it didn't work.  I also did the [Forms]![F-ClientSetUp]!ClientID and its working short term.
So if I leave it off both forms, how would the child form be affected?  Because the Child form is extremely specific to the parent form.
ASKER CERTIFIED SOLUTION
Avatar of Kelvin Sparks
Kelvin Sparks
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial