E
Eka1618
Hello,
What I am trying to accomplish is to give the user the ability to run a
report based on different criteria from 4 different tables:
tblLock
tblKey
tblLock_Key
tblPattern
I have created 2 select queries and a union query that combines both select
queries and that is also the record source for my report. I recently had to
add new criteria options to these queries and I am getting the error that the
expression is typed incorrectly or is too complex to be evaluated. My reports
ran fine untill I added the new criteria. I have double checked my spelling
and that seems to be ok, so I believe that my query is just too long.
I would like to hope that there is a simpler way to generate these queries,
the two select queries are extremely long. I do not really expect anyone to
analyze this code for code; I am just looking to learn of a different
technique to use to enable my users to generate this report however they wish.
Here are the 3 queires:
qryGeneralResultUnionRPT:
SELECT Q_INC, Q_ID, SAMPLE_NO, OBSERVATIONS, TEST_RESULTS, L_PART_NO,
K_PART_NO, PAT_NO, PAT_SIZE, L_FAILURE_MODE, K_FAILURE_MODE
FROM qryCustomGeneralRPT
UNION ALL SELECT Q_INC, Q_ID, SAMPLE_NO, OBSERVATIONS, TEST_RESULTS,
L_PART_NO, K_PART_NO, PAT_NO, PAT_SIZE, L_FAILURE_MODE, K_FAILURE_MODE
FROM qryCustomMultiGeneralRPT
ORDER BY qryCustomGeneralRPT.Q_INC;
qryCustomGeneralRPT:
SELECT tblResults.Q_INC, tblResults.Q_ID, tblResults.SAMPLE_NO,
tblResults.OBSERVATIONS, tblResults.TEST_RESULTS, tblResults.L_PART_NO,
tblResults.K_PART_NO, tblResults.PAT_NO, tblResults.PAT_SIZE,
tblResults.L_ID, tblResults.K_ID, tblResults.L_FAILURE_MODE,
tblResults.K_FAILURE_MODE
FROM tblResults
WHERE ((tblResults.L_ID)
In (select L_ID from tblLock
Where (L_EWO_NO = [forms].[frmCustomResultReport].[cmbLEWO] OR
[forms].[frmCustomResultReport].[cmbLEWO] = "<all>") AND (L_PART_NO =
[forms].[frmCustomResultReport].[cmbLPart] OR
[forms].[frmCustomResultReport].[cmbLPart] = "<all>") AND (L_SKID_NO =
[forms].[frmCustomResultReport].[cmbLSKID] OR
[forms].[frmCustomResultReport].[cmbLSKID] = "<all>") AND (L_MAT_TYPE =
[forms].[frmCustomResultReport].[cmbLMatType] OR
[forms].[frmCustomResultReport].[cmbLMatType] = "<all>") AND (L_MAT_HEAT =
[forms].[frmCustomResultReport].[cmbLMatHeat] OR
[forms].[frmCustomResultReport].[cmbLMatHeat] = "<all>") AND (L_HARD_SCALE =
[forms].[frmCustomResultReport].[cmbLHardScale] OR
[forms].[frmCustomResultReport].[cmbLHardScale] = "<all>") AND
(L_HARD_VALUE_HIGH = [forms].[frmCustomResultReport].[cmbLHardValueHigh] OR
[forms].[frmCustomResultReport].[cmbLHardValueHigh] = "<all>") AND
(L_HARD_VALUE_LOW = [forms].[frmCustomResultReport].[cmbLHardValueLow] OR
[forms].[frmCustomResultReport].[cmbLHardValueLow] = "<all>") AND (L_PLAT =
[forms].[frmCustomResultReport].[cmbLPlat] OR
[forms].[frmCustomResultReport].[cmbLPlat] = "<all>") AND (L_TOP_COAT =
[forms].[frmCustomResultReport].[cmbLCoat] OR
[forms].[frmCustomResultReport].[cmbLCoat] = "<all>") AND (L_THREAD =
[forms].[frmCustomResultReport].[cmbLThread] OR
[forms].[frmCustomResultReport].[cmbLThread] = "<all>") )
AND (tblResults.K_ID) IN (Select K_ID from tblKey Where (K_EWO_NO =
[forms].[frmCustomResultReport].[cmbKEWO] OR
[forms].[frmCustomResultReport].[cmbKEWO] = "<all>") AND (K_PART_NO =
[forms].[frmCustomResultReport].[cmbKPart] OR
[forms].[frmCustomResultReport].[cmbKPart] = "<all>") AND (K_SKID_NO =
[forms].[frmCustomResultReport].[cmbKSKID] OR
[forms].[frmCustomResultReport].[cmbKSKID] = "<all>") AND (K_MAT_TYPE =
[forms].[frmCustomResultReport].[cmbKMatType] OR
[forms].[frmCustomResultReport].[cmbKMatType] = "<all>") AND (K_MAT_HEAT =
[forms].[frmCustomResultReport].[cmbKMatHeat] OR
[forms].[frmCustomResultReport].[cmbKMatHeat] = "<all>") AND (K_HARD_SCALE =
[forms].[frmCustomResultReport].[cmbKHardScale] OR
[forms].[frmCustomResultReport].[cmbKHardScale] = "<all>") AND (K_PLAT =
[forms].[frmCustomResultReport].[cmbKPlat] OR
[forms].[frmCustomResultReport].[cmbKPlat] = "<all>") AND (K_TOP_COAT =
[forms].[frmCustomResultReport].[cmbKCoat] OR
[forms].[frmCustomResultReport].[cmbKCoat] = "<all>") )
AND (tblResults.PAT_NO) IN (Select PAT_NO from tblPattern Where ( PAT_NO =
[forms].[frmCustomResultReport].[cmbPatNo] OR
[forms].[frmCustomResultReport].[cmbPatNo] = 0) )
AND (tblResults.PAT_SIZE) IN (Select PAT_SIZE from tblPattern Where
(PAT_SIZE = [forms].[frmCustomResultReport].[cmbPatSize] OR
[forms].[frmCustomResultReport].[cmbPatSize] = "<all>" ))
AND tblResults.TEST_TYPE = "GENERAL" );
qryCustomMultiGeneralRPT:
SELECT tblResults.Q_INC, tblResults.Q_ID, tblResults.SAMPLE_NO,
tblResults.OBSERVATIONS, tblResults.TEST_RESULTS, tblResults.L_PART_NO,
tblResults.K_PART_NO, tblResults.PAT_NO, tblResults.PAT_SIZE,
tblResults.L_ID, tblResults.K_ID, tblResults.L_FAILURE_MODE,
tblResults.K_FAILURE_MODE
FROM tblResults
WHERE ((tblResults.L_K_ID)
In (select L_K_ID from tblLock_Key
Where (L_EWO_NO = [forms].[frmCustomResultReport].[cmbLEWO] OR
[forms].[frmCustomResultReport].[cmbLEWO] = "<all>") AND (L_PART_NO =
[forms].[frmCustomResultReport].[cmbLPart] OR
[forms].[frmCustomResultReport].[cmbLPart] = "<all>") AND (L_SKID_NO =
[forms].[frmCustomResultReport].[cmbLSKID] OR
[forms].[frmCustomResultReport].[cmbLSKID] = "<all>") AND (L_MAT_TYPE =
[forms].[frmCustomResultReport].[cmbLMatType] OR
[forms].[frmCustomResultReport].[cmbLMatType] = "<all>") AND (L_MAT_HEAT =
[forms].[frmCustomResultReport].[cmbLMatHeat] OR
[forms].[frmCustomResultReport].[cmbLMatHeat] = "<all>") AND (L_HARD_SCALE =
[forms].[frmCustomResultReport].[cmbLHardScale] OR
[forms].[frmCustomResultReport].[cmbLHardScale] = "<all>") AND
(L_HARD_VALUE_HIGH = [forms].[frmCustomResultReport].[cmbLHardValueHigh] OR
[forms].[frmCustomResultReport].[cmbLHardValueHigh] = "<all>") AND
(L_HARD_VALUE_LOW = [forms].[frmCustomResultReport].[cmbLHardValueLow] OR
[forms].[frmCustomResultReport].[cmbLHardValueLow] = "<all>") AND (L_PLAT =
[forms].[frmCustomResultReport].[cmbLPlat] OR
[forms].[frmCustomResultReport].[cmbLPlat] = "<all>") AND (L_TOP_COAT =
[forms].[frmCustomResultReport].[cmbLCoat] OR
[forms].[frmCustomResultReport].[cmbLCoat] = "<all>") AND (L_THREAD =
[forms].[frmCustomResultReport].[cmbLThread] OR
[forms].[frmCustomResultReport].[cmbLThread] = "<all>") AND (K_EWO_NO =
[forms].[frmCustomResultReport].[cmbKEWO] OR
[forms].[frmCustomResultReport].[cmbKEWO] = "<all>") AND (K_PART_NO =
[forms].[frmCustomResultReport].[cmbKPart] OR
[forms].[frmCustomResultReport].[cmbKPart] = "<all>") AND (K_SKID_NO =
[forms].[frmCustomResultReport].[cmbKSKID] OR
[forms].[frmCustomResultReport].[cmbKSKID] = "<all>") AND (K_MAT_TYPE =
[forms].[frmCustomResultReport].[cmbKMatType] OR
[forms].[frmCustomResultReport].[cmbKMatType] = "<all>") AND (K_MAT_HEAT =
[forms].[frmCustomResultReport].[cmbKMatHeat] OR
[forms].[frmCustomResultReport].[cmbKMatHeat] = "<all>") AND (K_HARD_SCALE =
[forms].[frmCustomResultReport].[cmbKHardScale] OR
[forms].[frmCustomResultReport].[cmbKHardScale] = "<all>") AND (K_PLAT =
[forms].[frmCustomResultReport].[cmbKPlat] OR
[forms].[frmCustomResultReport].[cmbKPlat] = "<all>") AND (K_TOP_COAT =
[forms].[frmCustomResultReport].[cmbKCoat] OR
[forms].[frmCustomResultReport].[cmbKCoat] = "<all>") )
AND (tblResults.PAT_NO) IN (Select PAT_NO from tblLKPattern Where ( PAT_NO =
[forms].[frmCustomResultReport].[cmbPatNo] OR
[forms].[frmCustomResultReport].[cmbPatNo] = 0) )
AND (tblResults.PAT_SIZE) IN (Select PAT_SIZE from tblLKPattern Where
(PAT_SIZE = [forms].[frmCustomResultReport].[cmbPatSize] OR
[forms].[frmCustomResultReport].[cmbPatSize] = "<all>" ))
AND tblResults.TEST_TYPE = "GENERAL" );
If anyone has any suggestions, please let me know, Thank You!
What I am trying to accomplish is to give the user the ability to run a
report based on different criteria from 4 different tables:
tblLock
tblKey
tblLock_Key
tblPattern
I have created 2 select queries and a union query that combines both select
queries and that is also the record source for my report. I recently had to
add new criteria options to these queries and I am getting the error that the
expression is typed incorrectly or is too complex to be evaluated. My reports
ran fine untill I added the new criteria. I have double checked my spelling
and that seems to be ok, so I believe that my query is just too long.
I would like to hope that there is a simpler way to generate these queries,
the two select queries are extremely long. I do not really expect anyone to
analyze this code for code; I am just looking to learn of a different
technique to use to enable my users to generate this report however they wish.
Here are the 3 queires:
qryGeneralResultUnionRPT:
SELECT Q_INC, Q_ID, SAMPLE_NO, OBSERVATIONS, TEST_RESULTS, L_PART_NO,
K_PART_NO, PAT_NO, PAT_SIZE, L_FAILURE_MODE, K_FAILURE_MODE
FROM qryCustomGeneralRPT
UNION ALL SELECT Q_INC, Q_ID, SAMPLE_NO, OBSERVATIONS, TEST_RESULTS,
L_PART_NO, K_PART_NO, PAT_NO, PAT_SIZE, L_FAILURE_MODE, K_FAILURE_MODE
FROM qryCustomMultiGeneralRPT
ORDER BY qryCustomGeneralRPT.Q_INC;
qryCustomGeneralRPT:
SELECT tblResults.Q_INC, tblResults.Q_ID, tblResults.SAMPLE_NO,
tblResults.OBSERVATIONS, tblResults.TEST_RESULTS, tblResults.L_PART_NO,
tblResults.K_PART_NO, tblResults.PAT_NO, tblResults.PAT_SIZE,
tblResults.L_ID, tblResults.K_ID, tblResults.L_FAILURE_MODE,
tblResults.K_FAILURE_MODE
FROM tblResults
WHERE ((tblResults.L_ID)
In (select L_ID from tblLock
Where (L_EWO_NO = [forms].[frmCustomResultReport].[cmbLEWO] OR
[forms].[frmCustomResultReport].[cmbLEWO] = "<all>") AND (L_PART_NO =
[forms].[frmCustomResultReport].[cmbLPart] OR
[forms].[frmCustomResultReport].[cmbLPart] = "<all>") AND (L_SKID_NO =
[forms].[frmCustomResultReport].[cmbLSKID] OR
[forms].[frmCustomResultReport].[cmbLSKID] = "<all>") AND (L_MAT_TYPE =
[forms].[frmCustomResultReport].[cmbLMatType] OR
[forms].[frmCustomResultReport].[cmbLMatType] = "<all>") AND (L_MAT_HEAT =
[forms].[frmCustomResultReport].[cmbLMatHeat] OR
[forms].[frmCustomResultReport].[cmbLMatHeat] = "<all>") AND (L_HARD_SCALE =
[forms].[frmCustomResultReport].[cmbLHardScale] OR
[forms].[frmCustomResultReport].[cmbLHardScale] = "<all>") AND
(L_HARD_VALUE_HIGH = [forms].[frmCustomResultReport].[cmbLHardValueHigh] OR
[forms].[frmCustomResultReport].[cmbLHardValueHigh] = "<all>") AND
(L_HARD_VALUE_LOW = [forms].[frmCustomResultReport].[cmbLHardValueLow] OR
[forms].[frmCustomResultReport].[cmbLHardValueLow] = "<all>") AND (L_PLAT =
[forms].[frmCustomResultReport].[cmbLPlat] OR
[forms].[frmCustomResultReport].[cmbLPlat] = "<all>") AND (L_TOP_COAT =
[forms].[frmCustomResultReport].[cmbLCoat] OR
[forms].[frmCustomResultReport].[cmbLCoat] = "<all>") AND (L_THREAD =
[forms].[frmCustomResultReport].[cmbLThread] OR
[forms].[frmCustomResultReport].[cmbLThread] = "<all>") )
AND (tblResults.K_ID) IN (Select K_ID from tblKey Where (K_EWO_NO =
[forms].[frmCustomResultReport].[cmbKEWO] OR
[forms].[frmCustomResultReport].[cmbKEWO] = "<all>") AND (K_PART_NO =
[forms].[frmCustomResultReport].[cmbKPart] OR
[forms].[frmCustomResultReport].[cmbKPart] = "<all>") AND (K_SKID_NO =
[forms].[frmCustomResultReport].[cmbKSKID] OR
[forms].[frmCustomResultReport].[cmbKSKID] = "<all>") AND (K_MAT_TYPE =
[forms].[frmCustomResultReport].[cmbKMatType] OR
[forms].[frmCustomResultReport].[cmbKMatType] = "<all>") AND (K_MAT_HEAT =
[forms].[frmCustomResultReport].[cmbKMatHeat] OR
[forms].[frmCustomResultReport].[cmbKMatHeat] = "<all>") AND (K_HARD_SCALE =
[forms].[frmCustomResultReport].[cmbKHardScale] OR
[forms].[frmCustomResultReport].[cmbKHardScale] = "<all>") AND (K_PLAT =
[forms].[frmCustomResultReport].[cmbKPlat] OR
[forms].[frmCustomResultReport].[cmbKPlat] = "<all>") AND (K_TOP_COAT =
[forms].[frmCustomResultReport].[cmbKCoat] OR
[forms].[frmCustomResultReport].[cmbKCoat] = "<all>") )
AND (tblResults.PAT_NO) IN (Select PAT_NO from tblPattern Where ( PAT_NO =
[forms].[frmCustomResultReport].[cmbPatNo] OR
[forms].[frmCustomResultReport].[cmbPatNo] = 0) )
AND (tblResults.PAT_SIZE) IN (Select PAT_SIZE from tblPattern Where
(PAT_SIZE = [forms].[frmCustomResultReport].[cmbPatSize] OR
[forms].[frmCustomResultReport].[cmbPatSize] = "<all>" ))
AND tblResults.TEST_TYPE = "GENERAL" );
qryCustomMultiGeneralRPT:
SELECT tblResults.Q_INC, tblResults.Q_ID, tblResults.SAMPLE_NO,
tblResults.OBSERVATIONS, tblResults.TEST_RESULTS, tblResults.L_PART_NO,
tblResults.K_PART_NO, tblResults.PAT_NO, tblResults.PAT_SIZE,
tblResults.L_ID, tblResults.K_ID, tblResults.L_FAILURE_MODE,
tblResults.K_FAILURE_MODE
FROM tblResults
WHERE ((tblResults.L_K_ID)
In (select L_K_ID from tblLock_Key
Where (L_EWO_NO = [forms].[frmCustomResultReport].[cmbLEWO] OR
[forms].[frmCustomResultReport].[cmbLEWO] = "<all>") AND (L_PART_NO =
[forms].[frmCustomResultReport].[cmbLPart] OR
[forms].[frmCustomResultReport].[cmbLPart] = "<all>") AND (L_SKID_NO =
[forms].[frmCustomResultReport].[cmbLSKID] OR
[forms].[frmCustomResultReport].[cmbLSKID] = "<all>") AND (L_MAT_TYPE =
[forms].[frmCustomResultReport].[cmbLMatType] OR
[forms].[frmCustomResultReport].[cmbLMatType] = "<all>") AND (L_MAT_HEAT =
[forms].[frmCustomResultReport].[cmbLMatHeat] OR
[forms].[frmCustomResultReport].[cmbLMatHeat] = "<all>") AND (L_HARD_SCALE =
[forms].[frmCustomResultReport].[cmbLHardScale] OR
[forms].[frmCustomResultReport].[cmbLHardScale] = "<all>") AND
(L_HARD_VALUE_HIGH = [forms].[frmCustomResultReport].[cmbLHardValueHigh] OR
[forms].[frmCustomResultReport].[cmbLHardValueHigh] = "<all>") AND
(L_HARD_VALUE_LOW = [forms].[frmCustomResultReport].[cmbLHardValueLow] OR
[forms].[frmCustomResultReport].[cmbLHardValueLow] = "<all>") AND (L_PLAT =
[forms].[frmCustomResultReport].[cmbLPlat] OR
[forms].[frmCustomResultReport].[cmbLPlat] = "<all>") AND (L_TOP_COAT =
[forms].[frmCustomResultReport].[cmbLCoat] OR
[forms].[frmCustomResultReport].[cmbLCoat] = "<all>") AND (L_THREAD =
[forms].[frmCustomResultReport].[cmbLThread] OR
[forms].[frmCustomResultReport].[cmbLThread] = "<all>") AND (K_EWO_NO =
[forms].[frmCustomResultReport].[cmbKEWO] OR
[forms].[frmCustomResultReport].[cmbKEWO] = "<all>") AND (K_PART_NO =
[forms].[frmCustomResultReport].[cmbKPart] OR
[forms].[frmCustomResultReport].[cmbKPart] = "<all>") AND (K_SKID_NO =
[forms].[frmCustomResultReport].[cmbKSKID] OR
[forms].[frmCustomResultReport].[cmbKSKID] = "<all>") AND (K_MAT_TYPE =
[forms].[frmCustomResultReport].[cmbKMatType] OR
[forms].[frmCustomResultReport].[cmbKMatType] = "<all>") AND (K_MAT_HEAT =
[forms].[frmCustomResultReport].[cmbKMatHeat] OR
[forms].[frmCustomResultReport].[cmbKMatHeat] = "<all>") AND (K_HARD_SCALE =
[forms].[frmCustomResultReport].[cmbKHardScale] OR
[forms].[frmCustomResultReport].[cmbKHardScale] = "<all>") AND (K_PLAT =
[forms].[frmCustomResultReport].[cmbKPlat] OR
[forms].[frmCustomResultReport].[cmbKPlat] = "<all>") AND (K_TOP_COAT =
[forms].[frmCustomResultReport].[cmbKCoat] OR
[forms].[frmCustomResultReport].[cmbKCoat] = "<all>") )
AND (tblResults.PAT_NO) IN (Select PAT_NO from tblLKPattern Where ( PAT_NO =
[forms].[frmCustomResultReport].[cmbPatNo] OR
[forms].[frmCustomResultReport].[cmbPatNo] = 0) )
AND (tblResults.PAT_SIZE) IN (Select PAT_SIZE from tblLKPattern Where
(PAT_SIZE = [forms].[frmCustomResultReport].[cmbPatSize] OR
[forms].[frmCustomResultReport].[cmbPatSize] = "<all>" ))
AND tblResults.TEST_TYPE = "GENERAL" );
If anyone has any suggestions, please let me know, Thank You!