Solved Cannot add records to subform. (1 Viewer)

ClaraBarton

Registered User.
Local time
Today, 06:50
Joined
Oct 14, 2019
Messages
463
This is a subform that goes on a recipe form (RecipeID to RecipeIDFK). Everything worked fine until I added the qryMeasure to the subform. Now the subform is not updatable although the query itself is updatable. The new records on the subform show error in the RecipeIDFK. I considered using a subform for the Measure on the ingredient subform but that doesn't work. Am I overlooking something obvious?

1697485314140.png
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 06:50
Joined
Oct 29, 2018
Messages
21,473
Sometimes, using an OUTER JOIN could render the query result as read only.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:50
Joined
May 21, 2018
Messages
8,529
Are you using a lookup table for ingredientidfk?
 

GPGeorge

Grover Park George
Local time
Today, 06:50
Joined
Nov 25, 2004
Messages
1,872
This is a left join and I want it editable
Unfortunately, though, it may not be editable. You need to consider alternatives.

I'm sort of guessing, though, that you may not need the unitID in the table bound to the subform anyway.

We really need to see the tables involved and possibly even a sample accdb to anlyze.
 

Mike Krailo

Well-known member
Local time
Today, 09:50
Joined
Mar 28, 2020
Messages
1,044
Why not create one query based on all the tables instead of a table to a query?
 

Mike Krailo

Well-known member
Local time
Today, 09:50
Joined
Mar 28, 2020
Messages
1,044
This is a subform that goes on a recipe form (RecipeID to RecipeIDFK). Everything worked fine until I added the qryMeasure to the subform. Now the subform is not updatable although the query itself is updatable. The new records on the subform show error in the RecipeIDFK. I considered using a subform for the Measure on the ingredient subform but that doesn't work. Am I overlooking something obvious?

View attachment 110394
After looking at this more closely, you should post your table relationships. The units of measure should be in the joining table for recipe to ingredients. You currently have the units in a query which doesn't make any sense to me as it has both UnitIDFK and Unit. It should simply be the join table which acts as a steps to build the recipe as well. See following diagram for example.

1697495362738.png
 

ClaraBarton

Registered User.
Local time
Today, 06:50
Joined
Oct 14, 2019
Messages
463
1697499622321.png

Code:
qryMeasure
SELECT tblIngredientUnit.UnitIDFK, tblIngredientUnit.QuantityText, tblUnits.Unit, [QuantityText] & " " & [Unit] AS Measure, tblIngredientUnit.IngredientIDFK
FROM tblUnits
RIGHT JOIN tblIngredientUnit ON tblUnits.UnitID = tblIngredientUnit.UnitIDFK;
Code:
qryIngredient
SELECT t_ingredient.IngredientID, t_ingredient.RecipeIDFK, t_ingredient.ingredienttext, t_ingredient.USDAIDFK, t_ingredient.ingredientindex, t_ingredient.heading, qryMeasure.QuantityText, qryMeasure.Unit, qryMeasure.Measure, qryMeasure.IngredientIDFK, qryMeasure.UnitIDFK
FROM t_ingredient
LEFT JOIN qryMeasure ON t_ingredient.IngredientID = qryMeasure.IngredientIDFK
ORDER BY t_ingredient.ingredientindex;
 

cheekybuddha

AWF VIP
Local time
Today, 14:50
Joined
Jul 21, 2014
Messages
2,280
Try adding tblIngredientUnit.tblIUID to qryMeasure.

Sometimes you need the PK to make the query updateable
 

ClaraBarton

Registered User.
Local time
Today, 06:50
Joined
Oct 14, 2019
Messages
463
The query was always updatable. It just didn't work in the subform. I went back and redid the tables. I decided it wasn't a true many to many so I added the tblIngredientUnit information to the t_ingredient table. It's now working and I thank you for your time.
 

ClaraBarton

Registered User.
Local time
Today, 06:50
Joined
Oct 14, 2019
Messages
463
And just to confess my sins... I discovered that the UnitIDFK on t_ingredients was a short text type instead of a number. Never would have worked!
 

Users who are viewing this thread

Top Bottom