Database listbox to textbox output

M

mtnc6

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
 
J

John W. Vinson

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

First off... Forms don't store data. Textboxes don't store data.

Tables store data in Fields. Forms (and textboxes and other controls) are just
windows, tools to display data stored in tables.

Secondly, you should *probably* (I don't know your database design so this may
be incorrect) have a table of Foods with a numeric foodID and a separate Text
datatype field with the food name. The food name would be stored *ONLY* in
this table - any other table would contain only the FoodID, and you'ld use a
tool like a combo box or listbox to actually store the FoodID while displaying
the food name.

Could you describe your tables and how (if at all) they're related?
 
M

mtnc6

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.

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.

Hope you understand this.

Thanks
Mtnc6
 
J

John W. Vinson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top