Control source of a text box

TasCat09

New member
Local time
Tomorrow, 04:23
Joined
Aug 7, 2016
Messages
10
Hello and thanks for allowing me to post.
I am new to access and am looking for some help from you guys who are much more experienced than me. I am developing a recipe database and on one particular form I want to set the value of txtIngredient1(text box) as the IngredientName(field in INGREDIENTS table) from the INGREDIENTS table where the ID(anotehr field in INGREDIENTS table) is equal to the value of the cboExistingIngredients (combobox) which is in the ADD_RECIPES form (as is txtIngredient1).

Here is the control source I have for the txtIngredient1 control:
=DLookUp("[IngredientName]","[INGREDIENTS]",[ID]=[Forms]![ADD_RECIPES]![cboExistingIngredients])

When the ID = 1, it works as I expect but is blank when the ID is anything other than 1. Can anyone help?
 
Why aren't you displaying the name of the ingredient in the combo box?

Let's assume you have some reason not to then I suggest including the name in the row source of the combo box. Then you could display the name in another text box by using the column property. Note that the column numbers are zero based so if the name is in the second column of the combo box the control source of the text box would be.

=cboExistingIngredients.Column(1)


I could be way off here. I'm not sure about what you are doing. I assume you must have at least a table for ingredients a table for recipes and a table for recipe ingredients. Could you tell us more how the ADD RECIPES form relates to the tables you have.
 
Thank you Sneuberg

That does exactly what I want. I was not aware I could use the column property like taht.

Thanks again
 

Users who are viewing this thread

Back
Top Bottom