mtnc6 said:
Hi to all. OK, as a rookie, I would like to ask for help regarding my
database problem.
Now, I have a form [mainfrm] with a textbox [txtfood] and a button which
launches a second form [frmlst]. The second form [frmlst] has a list box
[lstfood] control which contains food items.
What I want to do is that when i select the food item(s) in the [lstfood] of
the [frmlst] and I close that form, the items I selected will be entered in
the [txtfood] text box.
How can I make this happen?
I would highly appreciate any help guys.
Thanks,
Mtnc6
Hi. Thanks for the reply. Now I have the tables for the forms as you've
mentioned.
My tblFood has the following fields: foodID, foodName, Ingrd (ingredients),
comment. The second table [tblUsers] has: FirstName, LastName, Address, and
allFoods.
You're apparently using Microsoft's misleading, misdesigned, infuriating
"Multi Value Field" - right? Or are you storing "Flour, baking soda, milk,
shortening" in the Ingrd field? Don't!
You have a many to many relationship between both Foods and Ingredients, and
(apparently) between Foods and Users. To create a many to many relationship
you need THREE tables: e.g.
tblFoods
FoodID
FoodName
Comment
tblIngredients
IngredID
Ingedient
<other info, e.g. serving size, calories/serving, etc.>
tblRecipe
FoodID <link to tblFoods, what is this ingredient in>
IngredID <link to tblIngredients, what ingredient is in this food>
Amount
UnitOfMeasure
<other information about THIS ingredient in THIS food>
You'ld use a similar table structure to link people and foods.
First, the [mainfrm] has the fields of [tblUsers]. I also have a sub-form
with a source from [tblFood]. I made a combo box control [cboFoods] with the
[foodName] of the [tblFood] as the source list.
Now, what I want to happen is that when I add another food item from the
[cboFoods], the name of the food will be entered into [allFoods] text box
separated by commas.
Nope. You REALLY REALLY don't want to do this. You're using a relational
database, and one basic principle of relational databases is "atomicity" -
each field should store only one fact. Putting "Biscuits, Gravy, Orange juice,
Scrambled eggs" in a field in the users table is just making your task vastly
more difficult; searching and sorting will be far more difficult.
Hope you understand this.
I do. I just disagree with it. <g>
Check out the following, especially Crystal's tutorial chapter "Database
Design 101":
Jeff Conrad's resources page:
http://www.accessmvp.com/JConrad/accessjunkie/resources.html
The Access Web resources page:
http://www.mvps.org/access/resources/index.html
Roger Carlson's tutorials, samples and tips:
http://www.rogersaccesslibrary.com/
A free tutorial written by Crystal:
http://allenbrowne.com/casu-22.html
A video how-to series by Crystal:
http://www.YouTube.com/user/LearnAccessByCrystal
MVP Allen Browne's tutorials:
http://allenbrowne.com/links.html#Tutorials