Hello all,
I'm back with another SQL related problem. The details are below, but in short: I am using Access 2003. I have a table whose structure may include four different associate names per record (full structure below). I have a query that should return records that have one or more entered names (as criteria from a form) belonging to them.
TableName=COMPI LE_HIST
QueryName=Expor t Historical Query
[CODE=sql]
SELECT COMPILE_HIST.Co mpileID, COMPILE_HIST.Re sultsID, MONTH.Month, COMPILE_HIST.Ye ar, Market.Market, COMPILE_HIST.Cl ientID, COMPILE_HIST.Cl ientName, COMPILE_HIST.AE , COMPILE_HIST.NA C, COMPILE_HIST.Sa lesPerson, COMPILE_HIST.Sa lesManager
FROM COMPILE_HIST, [MONTH], Market
WHERE (COMPILE_HIST.M onth=MONTH.Mont hID) And (COMPILE_HIST.M arketID=Market. MarketID) AND ((COMPILE_HIST. NAC) Like (Forms![Export Historical Form]!NAC) & "*") AND ((COMPILE_HIST. AE) Like (Forms![Export Historical Form]!AE) & "*") AND ((COMPILE_HIST. SalesPerson) Like (Forms![Export Historical Form]!SalesP) & "*") AND ((COMPILE_HIST. SalesManager) Like (Forms![Export Historical Form]!SalesM) & "*")
ORDER BY COMPILE_HIST.Ye ar, MONTH.MonthID, Market.MarketID ;[/CODE]
My trouble is that the query returns (A) no results when it should or (B) all results when it should be filtered. I'm just not sure of how to phrase the sql to look at any and all entered criteria else just return everything.
As always, any help is appreciated - thank you in advance!
martin
I'm back with another SQL related problem. The details are below, but in short: I am using Access 2003. I have a table whose structure may include four different associate names per record (full structure below). I have a query that should return records that have one or more entered names (as criteria from a form) belonging to them.
TableName=COMPI LE_HIST
Code:
CompileID, autonumber, PK ResultsID, number Month, number, FK Year, number Market, number, FK ClientID,number, FK ClientName, text NAC, text (potential search criteria name) AE, text (potential search criteria name) SalesPerson, text (potential search criteria name) SalesManager, text (potential search criteria name)
[CODE=sql]
SELECT COMPILE_HIST.Co mpileID, COMPILE_HIST.Re sultsID, MONTH.Month, COMPILE_HIST.Ye ar, Market.Market, COMPILE_HIST.Cl ientID, COMPILE_HIST.Cl ientName, COMPILE_HIST.AE , COMPILE_HIST.NA C, COMPILE_HIST.Sa lesPerson, COMPILE_HIST.Sa lesManager
FROM COMPILE_HIST, [MONTH], Market
WHERE (COMPILE_HIST.M onth=MONTH.Mont hID) And (COMPILE_HIST.M arketID=Market. MarketID) AND ((COMPILE_HIST. NAC) Like (Forms![Export Historical Form]!NAC) & "*") AND ((COMPILE_HIST. AE) Like (Forms![Export Historical Form]!AE) & "*") AND ((COMPILE_HIST. SalesPerson) Like (Forms![Export Historical Form]!SalesP) & "*") AND ((COMPILE_HIST. SalesManager) Like (Forms![Export Historical Form]!SalesM) & "*")
ORDER BY COMPILE_HIST.Ye ar, MONTH.MonthID, Market.MarketID ;[/CODE]
My trouble is that the query returns (A) no results when it should or (B) all results when it should be filtered. I'm just not sure of how to phrase the sql to look at any and all entered criteria else just return everything.
As always, any help is appreciated - thank you in advance!
martin
Comment