JasonPurdueEE
Technical User
Ok guys, this is probably a simple question for those of you who are more experienced with writing queries, but I'm stuck. I'm building a series of multi-select listboxes that come up with the criteria for the WHERE part of a query and pass the argument onto the querydef. All this is going fine, but I need a little help with writing the query. Here's what I need: the user can select none, one or many items from a single list box. there are 4 listboxes. I want the query to return records that match ALL the critera selected in ALL 4 listboxes. as it is now, it returns all the records that match the criteria for listbox1, listbox2...
Here's my SQL statement:
SELECT TblWrenchTimeLog.Date, TblWrenchTimeLog.WTL_ID, ComboBoxUnitID.Unit, Tbl_CrewID.Crew, TblWrenchTimeImpacts.WorkOrder, TblWrenchTimeCode.WTI_Code_Descr, TblWrenchTimeImpacts.[#ofEmployees], TblWrenchTimeImpacts.WTI_Mins, [TblWrenchTimeImpacts]![#ofEmployees]*[TblWrenchTimeImpacts]![WTI_Mins] AS TotWTIMins, TblWrenchTimeImpacts.Comment, TblWrenchTimeLog.TotalREGHours
FROM ((Tbl_CrewID INNER JOIN TblWrenchTimeLog ON Tbl_CrewID.Crew_ID = TblWrenchTimeLog.Crew_id) INNER JOIN (TblWrenchTimeCode INNER JOIN TblWrenchTimeImpacts ON TblWrenchTimeCode.WTI_Code = TblWrenchTimeImpacts.WTI_code) ON TblWrenchTimeLog.WTL_ID = TblWrenchTimeImpacts.WTL_id) INNER JOIN ComboBoxUnitID ON TblWrenchTimeLog.Unit_id = ComboBoxUnitID.UnitID
WHERE (((ComboBoxUnitID.Unit)='GC1')) OR (((ComboBoxUnitID.Unit)='GC2') AND ((Tbl_CrewID.Crew)='AEIT')) OR (((Tbl_CrewID.Crew)='MECH')) OR (((Tbl_CrewID.Crew)='PIPE')) OR (((Tbl_CrewID.Crew)='SCAF') AND ((TblWrenchTimeImpacts.WorkOrder)='33322401-01')) OR (((TblWrenchTimeImpacts.WorkOrder)='33322403-01')) OR (((TblWrenchTimeLog.Date) Between #6/6/2002# And #6/6/2004#) AND ((TblWrenchTimeImpacts.WorkOrder)='33325585-01') AND ((TblWrenchTimeCode.WTI_Code_Descr)='Breaks'));
any ideas on how to accomplish this? if clarification is needed, please let me know. many thanks in advance.
JASON
Here's my SQL statement:
SELECT TblWrenchTimeLog.Date, TblWrenchTimeLog.WTL_ID, ComboBoxUnitID.Unit, Tbl_CrewID.Crew, TblWrenchTimeImpacts.WorkOrder, TblWrenchTimeCode.WTI_Code_Descr, TblWrenchTimeImpacts.[#ofEmployees], TblWrenchTimeImpacts.WTI_Mins, [TblWrenchTimeImpacts]![#ofEmployees]*[TblWrenchTimeImpacts]![WTI_Mins] AS TotWTIMins, TblWrenchTimeImpacts.Comment, TblWrenchTimeLog.TotalREGHours
FROM ((Tbl_CrewID INNER JOIN TblWrenchTimeLog ON Tbl_CrewID.Crew_ID = TblWrenchTimeLog.Crew_id) INNER JOIN (TblWrenchTimeCode INNER JOIN TblWrenchTimeImpacts ON TblWrenchTimeCode.WTI_Code = TblWrenchTimeImpacts.WTI_code) ON TblWrenchTimeLog.WTL_ID = TblWrenchTimeImpacts.WTL_id) INNER JOIN ComboBoxUnitID ON TblWrenchTimeLog.Unit_id = ComboBoxUnitID.UnitID
WHERE (((ComboBoxUnitID.Unit)='GC1')) OR (((ComboBoxUnitID.Unit)='GC2') AND ((Tbl_CrewID.Crew)='AEIT')) OR (((Tbl_CrewID.Crew)='MECH')) OR (((Tbl_CrewID.Crew)='PIPE')) OR (((Tbl_CrewID.Crew)='SCAF') AND ((TblWrenchTimeImpacts.WorkOrder)='33322401-01')) OR (((TblWrenchTimeImpacts.WorkOrder)='33322403-01')) OR (((TblWrenchTimeLog.Date) Between #6/6/2002# And #6/6/2004#) AND ((TblWrenchTimeImpacts.WorkOrder)='33325585-01') AND ((TblWrenchTimeCode.WTI_Code_Descr)='Breaks'));
any ideas on how to accomplish this? if clarification is needed, please let me know. many thanks in advance.
JASON