Wow - so many thingings that can be done. Heres the text from that query
_________________________________________________________________
SELECT [daily food table].Date, [daily food table].Time, [daily food
table].Food AS [daily food table_Food], [daily food table].[Serving size] AS
[daily food table_Serving size], [daily food table].GramsCarbohydrates AS
[daily food table_GramsCarbohydrates], [daily food table].GramsProtein AS
[daily food table_GramsProtein], [daily food table].GramsFat AS [daily food
table_GramsFat], [daily food table].Calories AS [daily food table_Calories],
[daily food table].Sodium AS [daily food table_Sodium], [daily food
table].Vitamins AS [daily food table_Vitamins], [daily food table].PersonID
AS [daily food table_PersonID], [daily food table].Notes AS [daily food
table_Notes], [daily food table].Sugar AS [daily food table_Sugar], [Food
Table].Food AS [Food Table_Food], [Food Table].[Serving size] AS [Food
Table_Serving size], [Food Table].GramsCarbohydrates AS [Food
Table_GramsCarbohydrates], [Food Table].GramsProtein AS [Food
Table_GramsProtein], [Food Table].GramsFat AS [Food Table_GramsFat], [Food
Table].Calories AS [Food Table_Calories], [Food Table].Sodium AS [Food
Table_Sodium], [Food Table].Vitamins AS [Food Table_Vitamins], [Food
Table].PersonID AS [Food Table_PersonID], [Food Table].Notes AS [Food
Table_Notes], [Food Table].Sugar AS [Food Table_Sugar], [Food Table].*
FROM [Food Table] INNER JOIN [daily food table] ON ([Food Table].Food =
[daily food table].Food) AND ([Food Table].[Serving size] = [daily food
table].[Serving size]) AND ([Food Table].GramsCarbohydrates = [daily food
table].GramsCarbohydrates) AND ([Food Table].GramsProtein = [daily food
table].GramsProtein) AND ([Food Table].GramsFat = [daily food
table].GramsFat) AND ([Food Table].Calories = [daily food table].Calories);
Well... this doesn't seem right.
You're joining the two tables on what looks like *EVERY SINGLE FIELD*! Unless
there is a record in [daily food table] with exactly equal values of every one
of Food and Serving Size and Grams Carbohydrate and... <etc.> you won't see
anything; and if there IS a record with all those fields in both tables you're
storing all that data redundantly.
STOP. You're going about this *wrong*. Sorry, but you really are!
Each table should have:
- a Primary Key, some unique value that exists only in that one record in the
table.
- Fields containing data pertaining to that record. Attributes of the food -
GramsProtein, GramsFat, Calories - etc. - should exist only in the Foods
table; fields pertaining to a serving or a given day's portion - ServingSize
perhaps - should exist *ONLY* in the daily table.
You do not need, and emphatically *should not have*, lots of fields
overlapping in the two tables! You're using a relational database; use it
relationally! Relational databases use the "Grandmother's Pantry Principle":
"A place - ONE place! - for everything, everything in its place". The Foods
table should store information about foods... and that information should
*ONLY* be stored there. The servings table should contain a "foreign key" -
the Food if that's the primary key, or the FoodID if you have a numeric
primary key - as a link to the foods table, *AND NOTHING ELSE* about the food.
You don't *need* to store that information redundantly; that's what a Query or
a Subform or a Combo Box are for, to join data from two different tables
together.
Seriously: take a look at some of these tutorials. The relational data model
takes some real work to get your head around, but you'll find it incredibly
powerful when you do.
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
A free tutorial written by Crystal (MS Access MVP):
http://allenbrowne.com/casu-22.html
MVP Allen Browne's tutorials:
http://allenbrowne.com/links.html#Tutorials
Have a merry Christmas... now I've got to go check my apple dumplings and see
if the pumpkin pie (home-made whole wheat crust, local organic pumpkin,
neighbor's fresh eggs <g>) is cool enough to eat!
John W. Vinson [MVP]