First let me start by saying thank you in advance for all the outstanding information and support this forum has offered. This is my first post and this problem has had me tied in knots for months.
Essentially I need to build a report off a query or set of queries to calculate and compare two tables by certain fields. There are many columns in each table but the ones I am concerned with are;
Tables 1 (conducted)
City
State
College
County
Inspection type
user
date conducted
Table 2 (requirements)
City
State
College
County
Inspection type
Quantity required monthly
Quanitity required quarterly
I need to add up how many (inspection type) have been completed for each combination of city,state,college, and county. Then compare that total againts how many were required from table 2 with the same combination of city,state, college, and county.
The problem is that the table 1 values might be different than the table 2 values.
i.e. the requirement might be city 1, state 1, college 7, county null / the table 1 (conducted) records might have several records but they are listed against city 1, state 1, college 7, county 2.
If I ask the query to tell me how many un-fulfilled requirements last month against city 1, state 1, college 7 I need it to tell me WITHOUT concidering county because the combo box on the filter form for county was left blank.
------------
This is the SQL view for what i have so far but it doesnt count correctly. It thinks that if conducted lists a county and the requirement didnt list a county then it doesnt count/match.
Essentially I need to build a report off a query or set of queries to calculate and compare two tables by certain fields. There are many columns in each table but the ones I am concerned with are;
Tables 1 (conducted)
City
State
College
County
Inspection type
user
date conducted
Table 2 (requirements)
City
State
College
County
Inspection type
Quantity required monthly
Quanitity required quarterly
I need to add up how many (inspection type) have been completed for each combination of city,state,college, and county. Then compare that total againts how many were required from table 2 with the same combination of city,state, college, and county.
The problem is that the table 1 values might be different than the table 2 values.
i.e. the requirement might be city 1, state 1, college 7, county null / the table 1 (conducted) records might have several records but they are listed against city 1, state 1, college 7, county 2.
If I ask the query to tell me how many un-fulfilled requirements last month against city 1, state 1, college 7 I need it to tell me WITHOUT concidering county because the combo box on the filter form for county was left blank.
------------
This is the SQL view for what i have so far but it doesnt count correctly. It thinks that if conducted lists a county and the requirement didnt list a county then it doesnt count/match.
Code:
SELECT [RILS Builder Listing].Squadron, [RILS Builder Listing].Flight, [RILS Builder Listing].Section AS Sections, [RILS Builder Listing].Requirement, [RILS Builder Listing].[Inspection Type], Sum((nz([CountOfInspection Type]))) AS [Sum], [Inspection Type Listing].[Description of Inspection Type], [Inspection Type Listing].AQL
FROM ([RILS Builder Listing] LEFT JOIN [RILS count] ON ([RILS Builder Listing].Squadron = [RILS count].Squadron) AND ([RILS Builder Listing].Flight = [RILS count].Flight) AND ([RILS Builder Listing].[Inspection Type] = [RILS count].[Inspection Type])) INNER JOIN [Inspection Type Listing] ON [RILS Builder Listing].[Inspection Type] = [Inspection Type Listing].[Inspection Type]
GROUP BY [RILS Builder Listing].Squadron, [RILS Builder Listing].Flight, [RILS Builder Listing].Section, [RILS Builder Listing].Requirement, [RILS Builder Listing].[Inspection Type], [Inspection Type Listing].[Description of Inspection Type], [Inspection Type Listing].AQL
HAVING ((([RILS Builder Listing].Squadron) Like [Forms]![start page]![squadron] & "*") AND (([RILS Builder Listing].Flight) Like [Forms]![start page]![flight] & "*") AND (([RILS Builder Listing].Section) Like [Forms]![start page]![section] & "*") AND (([RILS Builder Listing].Requirement)>=1) AND ((Sum((nz([CountOfInspection Type]))))<[requirement])) OR ((([RILS Builder Listing].Squadron) Like [Forms]![start page]![squadron] & "*") AND (([RILS Builder Listing].Flight) Like [Forms]![start page]![flight] & "*") AND (([RILS Builder Listing].Section) Is Null) AND (([RILS Builder Listing].Requirement)>=1) AND ((Sum((nz([CountOfInspection Type]))))<[requirement])) OR ((([RILS Builder Listing].Squadron) Like [Forms]![start page]![squadron] & "*") AND (([RILS Builder Listing].Flight) Is Null) AND (([RILS Builder Listing].Section) Is Null) AND (([RILS Builder Listing].Requirement)>=1) AND ((Sum((nz([CountOfInspection Type]))))<[requirement]));