Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


MS Access Query Join 2 Tables Together for one Subform Master Child Link and cannot add record Join key of table 'ProdLocations' not in recordset

Posted on 2016-10-25
Medium Priority
Last Modified: 2016-10-26
I have a subform that is made by query of two tables joined.  The two tables are "ProdLocations" and "Products". This Subform is Linked to the Mainform by "SkuID".  I have most of it figured out but two thing.

1: The field "SkuID" which is found in the "Products" table is not auto populating like it should on a new entry.

2: If I was to click on the field "QtyLoc"  it errors with: cannot add record Join key of table 'ProdLocations' not in recordset. BUT if I click on the new record row and then back on "QtyLoc" then it will allow me to enter a Quantity. (Which I believe has to do with the "SkuID" above.

It is putting the information into the tables all correctly accept the "SkuID" in the "Products" Table

I know query joining tables for a subform isn't the best approach but I need a single form to enter fields"Condition ID" "Price" in the Products table and "QtyLoc" into the "Locations Table.

Subform Query:

SELECT Products.ConditionID, Products.Price, Products.ProductID, Products.ProdConSku, ProdLocations.ProdLocID, ProdLocations.LocID, ProdLocations.QtyLoc, Products.SkuID
FROM Products INNER JOIN ProdLocations ON Products.ProductID = ProdLocations.ProductID
WHERE (((ProdLocations.LocID)=1));

Open in new window


Question by:Dustin Stanley
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4

Expert Comment

ID: 41859615
because of the 1:M relationship between products and prodlocations, the product must exist before location can be added.
Clicking the 'new record' creates the required (product) record in the clone (ready for insert)
Is the SkuID in products defined as autonum?

Author Comment

by:Dustin Stanley
ID: 41859617
because of the 1:M relationship between products and prodlocations, the product must exist before location can be added.

My thoughts exactly but I didn't know if there was a work around in a nice clean fashion.

Is the SkuID in products defined as autonum?

It is a autonumber in SKUs table and then a Integer in the Products Table with no default.

Expert Comment

ID: 41859632
the skuid isn't auto populating because it isn't autonum (correct) but a foreign key. You need a drop-down (based on data from the SKUs table) for the user to select this in the subform.
Maybe put the Product fields first in the form?

I'm not convinced your design is sound. It looks as if you should have many products in a location, not many locations for a product. Alternatively, location would be an attribute of product?

Maybe the subform should be just location, and have a dropdown to select the product?
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.


Accepted Solution

COACHMAN99 earned 1000 total points
ID: 41859638
Sorry, disregard the above comment re design - I just noticed your M:M situation

Author Comment

by:Dustin Stanley
ID: 41859668
Redesign are you crazy! Seriously though I already started redesigning. I didn't see it working but kept praying it would. Thanks for the help. I could use some of your input though on the redesign. I will tell you want I need and if you could point me in the direction.

When a new product comes in and is entered into the database. I need the user to fill out 3 fields for the two tables.

Products table = ConditionID & Price

ProdLocations table = QtyLoc (Quantity)

Of course Products has to be filled out before Prodlocations and I have beforeinsert codes on the current Subforms for that to block the user and make them do it in a sequence.

There is a unique index on the ( ProductID & LocID).

Location 1 is the default in the ProdLocations and that is basically receiving area.

The user is responsible to enter the quantity they have available. It will default to the receiving location  (LocID 1) Automatically.

****If there is more items coming in and or found at a later time while there are still items currently in (LocID 1) then the user needs to be able to increase the quantity in (LocID 1)

What I have currently as my redesign it allows the user (Which I don't Like or want) to add multiple rows of quantity but then errors because of the unique index.

the Subform Products is linked by SkuID to the main form called frmSkusEntry.

The 2nd Subform for Prodlocations is linked to the Products Subform by Child ProductID and Master:


Open in new window

So if you could take that all in and give any suggestions that would be awesome.

I would like the subform (Subforms) to appear to be one combined subform and have only 4 records max showing (One for Each ConditionID: NSOP,NSSP,USOP,USSP) in the products and then Prodlocations to have 4 lines to match for the Quantity in (LocID 1).

Thank you for your time and thought!

Expert Comment

ID: 41859680
because you only want 1 qty for each prod/loc combination you don't want to have multiple rows. The user must 'update' the qty instead of adding a new record.

The alternative design-approach is transaction-based,  where users enter 'debits' or 'credit' transactions and you derive a total based on initial value plus sum of debits and credits, This is a bunch of work so I would stay with a single record as you have.

I am signing-off now but suggest you solve the first issue before going to 'One for Each ConditionID'
LVL 39

Assisted Solution

PatHartman earned 1000 total points
ID: 41861027
Please excuse me if I am off the wall.  I didn't try to digest the thread so far BUT - if the form is not populating the foreign key for the subform then -
1. Make sure that the query for the subform is selecting the correct foreign key.  You said the subform query uses multiple tables.  I don't know if one of those is the parent table.  If it is, you should delete the parent table since you don't need anything from the parent table in the subform.  If you keep it, you have to select the foreign key from the child table rather than the primary key from the main table since it is the foreign key that Access will populate based on the master/child links.
2. Make sure the master/child links are set correctly.

Author Comment

by:Dustin Stanley
ID: 41861035
Thanks pat. I have been redesigning and left this open for any advice I might use. I will come back and decide on what to do. Thanks again.

Author Closing Comment

by:Dustin Stanley
ID: 41861500
Redesign was necessary. Thank you for your time and ideas!

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question