[Access 2000] fill subform based on selection in dropdown
Posted on 2004-04-21
This should be an easy one for the veterans ;)
I have a table meal, meal-ingredient, and ingredient
I want to show all ingredients of a meal in the subform when you select a meal in de dropdown.
I have a dropdown box, and it is filled with a value from the table “meal”
This table contains an id, name, description
In the dropdown box you select the id, then I want access to look in the table meal-ingredient and select all the ingredient prim_keys connected to the meal. This table looks like
Meal_id | ingredient_id
so now I know witch ingredient belong to a certain meal, and I want the subform to show all the properties of the ingredients. In a dataform, so I can manually put the amounts in,
like this, it shows : potato, small cut, and then fill in by user: amount 0.5 kg
this should not be so hard, I have now:
choice_menu --> propertys: on change --> vba code
private sub choice_menu_change()
Dim strChoice As String
Dim strQuery As String
strChoice = me![choice_menu].Text
strQuery = Select meal.meal_id, ingredient.ingredient_id, ingredient.ingredient_description, ingredient.ingredient_ammount From ingredient innder join meal_ingredient_matchTabel on meail.meail_id = meal_ingredient_matchTabel.meal_id) On ingredient.ingredient_id = meal_ingredient_matchTabel.ingredient_id where (((meal.meal_id) = “& strChoice & “));
Me.Subform_ingredients.SourceObject = strQuery
The problem is.. access keeps on insisting that the subform doesnt exist…
Can somebody please help me out here.. I don’t thing this will be hard.. but I just can’t seem to get it right..
Thanks a lot!