mardon
asked on
Query Design
I have a query that has two fields that get the selection criteria from combo?s on a form. Criteria for field one is ?Like[forms].[frmOne].[cbo One]? (i.e. 1,2,3,4,5). Criteria for field two is ?Like[forms].[frmOne].[cbo Two]? (i.e. A,B,C,D,E). This works fine. However, there is data in field one that is not shown in cboOne (don?t want it shown). So, if cboTwo = E, I want the selection criteria for field one to be cboOne or 6. How do I accomplish this in the query design?
Hi,
Get the ListIndex of [forms].[frmOne].[cboOne] (Or using its Value Property) , then compare it using a Select .. Case Statement ? :
Example:
myIndex = [forms].[frmOne].[cboOne]. ListIndex
'Or myValue = [forms].[frmOne].[cboOne]. Value
Select Case myIndex 'myValue
Case 0:
Case 1:
Case 2:
.
.
.
Case 6:
Case Else:
End Select
regards.
Get the ListIndex of [forms].[frmOne].[cboOne] (Or using its Value Property) , then compare it using a Select .. Case Statement ? :
Example:
myIndex = [forms].[frmOne].[cboOne].
'Or myValue = [forms].[frmOne].[cboOne].
Select Case myIndex 'myValue
Case 0:
Case 1:
Case 2:
.
.
.
Case 6:
Case Else:
End Select
regards.
ASKER
ok - I tried that and I geet an error. Lets go one step farther, here is the resulting query:
SELECT TOP 20 Sum(MasterRSC.NMC) AS NMC, MasterRSC.WUC7, MasterRSC.Nomenclature, Sum(MasterRSC.NMCM) AS NMCM, Sum(MasterRSC.NMCS) AS NMCS, Sum(MasterRSC.DMMH) AS DMMH, Sum(MasterRSC.[CANN ACT]) AS CANNS, Sum(MasterRSC.BCM) AS BCMs, Sum(MasterRSC.[Items ML1]) AS ML1, Sum(MasterRSC.[Items ML2]) AS ML2, Sum(MasterRSC.RFI) AS RFI, WUC_BY_LEVEL.LEVEL_2
FROM MasterRSC INNER JOIN WUC_BY_LEVEL ON MasterRSC.WUC7 = WUC_BY_LEVEL.WUC
WHERE (((MasterRSC.TEC)=IIf([for ms].[frmRS CParmWUC]. [cboLevelT wo]="P&P", (MasterRSC .TEC)=[for ms].[frmRS CParmWUC]. [cboSelTec ] Or (MasterRSC.TEC)="TXA-",[fo rms].[frmR SCParmWUC] .[cboSelTe c])) AND ((MasterRSC.yrqtr) Between [forms].[frmRSCParmwuc].[c boBeginDat e] And [forms].[frmRSCParmwuc].[c boenddate] ))
GROUP BY MasterRSC.WUC7, MasterRSC.Nomenclature, WUC_BY_LEVEL.LEVEL_2
HAVING (((Sum(MasterRSC.NMC))>0) AND ((MasterRSC.Nomenclature) Not Like "*Not found*" And (MasterRSC.Nomenclature) Not Like "*noc*") AND ((WUC_BY_LEVEL.LEVEL_2) Like [forms].[frmRSCParmWUC].[c boLevelTwo ]))
ORDER BY Sum(MasterRSC.NMC) DESC
WITH OWNERACCESS OPTION;
Is it fixable???????
SELECT TOP 20 Sum(MasterRSC.NMC) AS NMC, MasterRSC.WUC7, MasterRSC.Nomenclature, Sum(MasterRSC.NMCM) AS NMCM, Sum(MasterRSC.NMCS) AS NMCS, Sum(MasterRSC.DMMH) AS DMMH, Sum(MasterRSC.[CANN ACT]) AS CANNS, Sum(MasterRSC.BCM) AS BCMs, Sum(MasterRSC.[Items ML1]) AS ML1, Sum(MasterRSC.[Items ML2]) AS ML2, Sum(MasterRSC.RFI) AS RFI, WUC_BY_LEVEL.LEVEL_2
FROM MasterRSC INNER JOIN WUC_BY_LEVEL ON MasterRSC.WUC7 = WUC_BY_LEVEL.WUC
WHERE (((MasterRSC.TEC)=IIf([for
GROUP BY MasterRSC.WUC7, MasterRSC.Nomenclature, WUC_BY_LEVEL.LEVEL_2
HAVING (((Sum(MasterRSC.NMC))>0) AND ((MasterRSC.Nomenclature) Not Like "*Not found*" And (MasterRSC.Nomenclature) Not Like "*noc*") AND ((WUC_BY_LEVEL.LEVEL_2) Like [forms].[frmRSCParmWUC].[c
ORDER BY Sum(MasterRSC.NMC) DESC
WITH OWNERACCESS OPTION;
Is it fixable???????
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I didn't do it exactly the way you describe, but from your comment found that the nested if was the problem. I used some code on the form and checked-changed the values where necessary. It works now, however crude! Thanks -
ASKER
Sorry about the delay - I intended my previous comment as accepting your comment; "I didn't do it exactly the way you describe, but from your comment found that the nested if was the problem. I used some code on the form and checked-changed the values where necessary. It works now,
however crude! Thanks - "
Thanks again!!
however crude! Thanks - "
Thanks again!!
Cheers.. The function I have mentioned would have been a object oriented approach as you can call it for any form to build a criteria.
IIf(forms].[frmOne].[cboTw
That might do the trick.
HTH,
Co