First of all your Site Weekly Counts table is a spreadsheet layout & isn't suitable for a database
Tables should be long and narrow - lots of records & few fields.
The data in that table should be obtained using a crosstab query when necessary
Secondly, although Dlookups can be used in tables, yours failed because it contained errors
The correct code is:
Code:
InProg1: DLookUp("[Count Prog1]","[Prog1 Lookup]","[Site Weekly Counts_SITE NAME] = '" & [SITE NAME] & "'")
But its best to avoid Dlookups in queries as it needs to be run for each record which is inefficient
In this case the query can easily be rewritten to get the same result:
Code:
SELECT [Site Weekly Counts].[SITE NAME], [Site Weekly Counts].[Week No], [Site Weekly Counts].[Meal Type], [Site Weekly Counts].Approved, [Site Weekly Counts].[Week Start], [Prog1 Lookup].[Count Prog1]FROM [Prog1 Lookup] RIGHT JOIN [Site Weekly Counts] ON [Prog1 Lookup].[Site Weekly Counts_SITE NAME] = [Site Weekly Counts].[SITE NAME];
NOTE: I have used an outer (right) join as one of your site names has no 'Count Prog1' value
SITE NAME |
Week No |
Meal Type |
Approved |
Week Start |
Count Prog1 |
AC Youth Enrichment Camp |
1 |
Breakfast |
|
26/06/2017 |
|
ACX Multicultural Center |
1 |
Breakfast |
400 |
25/06/2018 |
1 |
Cumberland County College |
2 |
Lunch |
55 |
02/07/2018 |
21 |
If you don't need those sites included, use an INNER join
Code:
SELECT [Site Weekly Counts].[SITE NAME], [Site Weekly Counts].[Week No], [Site Weekly Counts].[Meal Type], [Site Weekly Counts].Approved, [Site Weekly Counts].[Week Start], [Prog1 Lookup].[Count Prog1]
FROM [Prog1 Lookup] INNER JOIN [Site Weekly Counts] ON [Prog1 Lookup].[Site Weekly Counts_SITE NAME] = [Site Weekly Counts].[SITE NAME];
Thirdly, I STRONGLY recommend you use a simpler naming system for tables/fields/queries etc with no spaces - use 'CamelCase' instead
e.g. Site Weekly Counts_SITE NAME => SiteName
As for the main points of your post, I suggest having a form with combo boxes to allow users to select the required options.
These would then be combined to create SQL versions of queries e.g. for use in suitable reports
Happy to return to this later once you've had time to consider the above
See attached for modified & new queries