D
DawnTreader
hello
i have a problem.
i have a query where i want to have to possible criteria for one field and i
need the query to choose what criteria it should use.
here is the sql as it currently is:
SELECT tblSiteInformation.SiteID, tblProductList.ProductID,
Nz([CompanyName]," ") AS Company, tblSiteInformation.SiteCommonName,
subtblCountry.Country, subtblCity.City, tblProductList.SerialNumber,
tblProductList.ProductTypeID, qryProductWarrantyClaimCount.[# Claims],
qryProductIssueCount.Issues, qryProductLastServiceDate.LastServiceReport,
tblSiteInformation.CountryID, tblProductList.DateDeleted,
tblServiceReps.ServiceRepID, tblServiceReps.Name,
tblProductList.CustomerOrder, tblProductList.WorkOrder
FROM tblServiceReps RIGHT JOIN (tblCustomerList RIGHT JOIN (subtblCountry
RIGHT JOIN (subtblCity RIGHT JOIN (tblSiteInformation RIGHT JOIN
(qryProductIssueCount RIGHT JOIN (qryProductLastServiceDate RIGHT JOIN
(qryProductWarrantyClaimCount RIGHT JOIN tblProductList ON
qryProductWarrantyClaimCount.ProductID = tblProductList.ProductID) ON
qryProductLastServiceDate.ProductID = tblProductList.ProductID) ON
qryProductIssueCount.ProductID = tblProductList.ProductID) ON
tblSiteInformation.SiteID = tblProductList.SiteID) ON subtblCity.CityID =
tblSiteInformation.CityID) ON subtblCountry.CountryID =
tblSiteInformation.CountryID) ON tblCustomerList.IMWCustomerID =
tblSiteInformation.CustomerID) ON tblServiceReps.ServiceRepID =
tblSiteInformation.ServiceRepID
WHERE (((tblProductList.ProductID) Like [forms]![zzMAINFORM]![txtProduct])
AND ((Nz([CompanyName]," ")) Like "*" &
[forms]![zzMAINFORM]![txtCustomerHidden] & "*") AND
((tblSiteInformation.SiteCommonName) Like "*" &
[Forms]![zzMAINFORM]![txtSiteHidden] & "*") AND
((tblProductList.SerialNumber) Like "*" & [forms]![zzMAINFORM]![txtSerial] &
"*") AND ((tblProductList.ProductTypeID) Like
[Forms]![zzMAINFORM]![txtFilterProductType] & "*") AND
((tblSiteInformation.CountryID) Like [forms]![zzMAINFORM]![txtCountry]) AND
((tblProductList.DateDeleted) Is Null) AND ((tblServiceReps.ServiceRepID)
Like [Forms]![zzMAINFORM]![txtFilterRep]) AND ((tblProductList.CustomerOrder)
Like [Forms]![zzMAINFORM]![txtFilterOrder] Or (tblProductList.CustomerOrder)
Is Null) AND ((tblProductList.WorkOrder) Like
[Forms]![zzMAINFORM]![txtFilterWO] Or (tblProductList.WorkOrder) Is Null))
ORDER BY Nz([CompanyName]," "), tblSiteInformation.SiteCommonName,
subtblCountry.Country, tblProductList.SerialNumber;
here is what i would like:
SELECT tblSiteInformation.SiteID, tblProductList.ProductID,
Nz([CompanyName]," ") AS Company, tblSiteInformation.SiteCommonName,
subtblCountry.Country, subtblCity.City, tblProductList.SerialNumber,
tblProductList.ProductTypeID, qryProductWarrantyClaimCount.[# Claims],
qryProductIssueCount.Issues, qryProductLastServiceDate.LastServiceReport,
tblSiteInformation.CountryID, tblProductList.DateDeleted,
tblServiceReps.ServiceRepID, tblServiceReps.Name,
tblProductList.CustomerOrder, tblProductList.WorkOrder
FROM tblServiceReps RIGHT JOIN (tblCustomerList RIGHT JOIN (subtblCountry
RIGHT JOIN (subtblCity RIGHT JOIN (tblSiteInformation RIGHT JOIN
(qryProductIssueCount RIGHT JOIN (qryProductLastServiceDate RIGHT JOIN
(qryProductWarrantyClaimCount RIGHT JOIN tblProductList ON
qryProductWarrantyClaimCount.ProductID = tblProductList.ProductID) ON
qryProductLastServiceDate.ProductID = tblProductList.ProductID) ON
qryProductIssueCount.ProductID = tblProductList.ProductID) ON
tblSiteInformation.SiteID = tblProductList.SiteID) ON subtblCity.CityID =
tblSiteInformation.CityID) ON subtblCountry.CountryID =
tblSiteInformation.CountryID) ON tblCustomerList.IMWCustomerID =
tblSiteInformation.CustomerID) ON tblServiceReps.ServiceRepID =
tblSiteInformation.ServiceRepID
WHERE (((tblProductList.ProductID) Like [forms]![zzMAINFORM]![txtProduct])
AND ((Nz([CompanyName]," ")) Like "*" &
[forms]![zzMAINFORM]![txtCustomerHidden] & "*") AND
((tblSiteInformation.SiteCommonName) Like "*" &
[Forms]![zzMAINFORM]![txtSiteHidden] & "*") AND
((tblProductList.SerialNumber) Like "*" & [forms]![zzMAINFORM]![txtSerial] &
"*") AND ((tblProductList.ProductTypeID) Like
[Forms]![zzMAINFORM]![txtFilterProductType] & "*") AND
((tblSiteInformation.CountryID) Like [forms]![zzMAINFORM]![txtCountry]) AND
((tblProductList.DateDeleted) Is Null) AND ((tblServiceReps.ServiceRepID)
Like [Forms]![zzMAINFORM]![txtFilterRep]) AND ((tblProductList.CustomerOrder)
Like [Forms]![zzMAINFORM]![txtFilterOrder] Or (tblProductList.CustomerOrder)
Is Null) AND
((tblProductList.WorkOrder)=IIf([Forms]![zzMAINFORM]![txtFilterWO]="*",(tblProductList.WorkOrder)
Like [Forms]![zzMAINFORM]![txtFilterWO] Or (tblProductList.WorkOrder) Is
Null,(tblProductList.WorkOrder) Like [Forms]![zzMAINFORM]![txtFilterWO])))
ORDER BY Nz([CompanyName]," "), tblSiteInformation.SiteCommonName,
subtblCountry.Country, tblProductList.SerialNumber;
the problem is that access returns a too complex error.
is there any other way i can do what i am attempting?
i have a problem.
i have a query where i want to have to possible criteria for one field and i
need the query to choose what criteria it should use.
here is the sql as it currently is:
SELECT tblSiteInformation.SiteID, tblProductList.ProductID,
Nz([CompanyName]," ") AS Company, tblSiteInformation.SiteCommonName,
subtblCountry.Country, subtblCity.City, tblProductList.SerialNumber,
tblProductList.ProductTypeID, qryProductWarrantyClaimCount.[# Claims],
qryProductIssueCount.Issues, qryProductLastServiceDate.LastServiceReport,
tblSiteInformation.CountryID, tblProductList.DateDeleted,
tblServiceReps.ServiceRepID, tblServiceReps.Name,
tblProductList.CustomerOrder, tblProductList.WorkOrder
FROM tblServiceReps RIGHT JOIN (tblCustomerList RIGHT JOIN (subtblCountry
RIGHT JOIN (subtblCity RIGHT JOIN (tblSiteInformation RIGHT JOIN
(qryProductIssueCount RIGHT JOIN (qryProductLastServiceDate RIGHT JOIN
(qryProductWarrantyClaimCount RIGHT JOIN tblProductList ON
qryProductWarrantyClaimCount.ProductID = tblProductList.ProductID) ON
qryProductLastServiceDate.ProductID = tblProductList.ProductID) ON
qryProductIssueCount.ProductID = tblProductList.ProductID) ON
tblSiteInformation.SiteID = tblProductList.SiteID) ON subtblCity.CityID =
tblSiteInformation.CityID) ON subtblCountry.CountryID =
tblSiteInformation.CountryID) ON tblCustomerList.IMWCustomerID =
tblSiteInformation.CustomerID) ON tblServiceReps.ServiceRepID =
tblSiteInformation.ServiceRepID
WHERE (((tblProductList.ProductID) Like [forms]![zzMAINFORM]![txtProduct])
AND ((Nz([CompanyName]," ")) Like "*" &
[forms]![zzMAINFORM]![txtCustomerHidden] & "*") AND
((tblSiteInformation.SiteCommonName) Like "*" &
[Forms]![zzMAINFORM]![txtSiteHidden] & "*") AND
((tblProductList.SerialNumber) Like "*" & [forms]![zzMAINFORM]![txtSerial] &
"*") AND ((tblProductList.ProductTypeID) Like
[Forms]![zzMAINFORM]![txtFilterProductType] & "*") AND
((tblSiteInformation.CountryID) Like [forms]![zzMAINFORM]![txtCountry]) AND
((tblProductList.DateDeleted) Is Null) AND ((tblServiceReps.ServiceRepID)
Like [Forms]![zzMAINFORM]![txtFilterRep]) AND ((tblProductList.CustomerOrder)
Like [Forms]![zzMAINFORM]![txtFilterOrder] Or (tblProductList.CustomerOrder)
Is Null) AND ((tblProductList.WorkOrder) Like
[Forms]![zzMAINFORM]![txtFilterWO] Or (tblProductList.WorkOrder) Is Null))
ORDER BY Nz([CompanyName]," "), tblSiteInformation.SiteCommonName,
subtblCountry.Country, tblProductList.SerialNumber;
here is what i would like:
SELECT tblSiteInformation.SiteID, tblProductList.ProductID,
Nz([CompanyName]," ") AS Company, tblSiteInformation.SiteCommonName,
subtblCountry.Country, subtblCity.City, tblProductList.SerialNumber,
tblProductList.ProductTypeID, qryProductWarrantyClaimCount.[# Claims],
qryProductIssueCount.Issues, qryProductLastServiceDate.LastServiceReport,
tblSiteInformation.CountryID, tblProductList.DateDeleted,
tblServiceReps.ServiceRepID, tblServiceReps.Name,
tblProductList.CustomerOrder, tblProductList.WorkOrder
FROM tblServiceReps RIGHT JOIN (tblCustomerList RIGHT JOIN (subtblCountry
RIGHT JOIN (subtblCity RIGHT JOIN (tblSiteInformation RIGHT JOIN
(qryProductIssueCount RIGHT JOIN (qryProductLastServiceDate RIGHT JOIN
(qryProductWarrantyClaimCount RIGHT JOIN tblProductList ON
qryProductWarrantyClaimCount.ProductID = tblProductList.ProductID) ON
qryProductLastServiceDate.ProductID = tblProductList.ProductID) ON
qryProductIssueCount.ProductID = tblProductList.ProductID) ON
tblSiteInformation.SiteID = tblProductList.SiteID) ON subtblCity.CityID =
tblSiteInformation.CityID) ON subtblCountry.CountryID =
tblSiteInformation.CountryID) ON tblCustomerList.IMWCustomerID =
tblSiteInformation.CustomerID) ON tblServiceReps.ServiceRepID =
tblSiteInformation.ServiceRepID
WHERE (((tblProductList.ProductID) Like [forms]![zzMAINFORM]![txtProduct])
AND ((Nz([CompanyName]," ")) Like "*" &
[forms]![zzMAINFORM]![txtCustomerHidden] & "*") AND
((tblSiteInformation.SiteCommonName) Like "*" &
[Forms]![zzMAINFORM]![txtSiteHidden] & "*") AND
((tblProductList.SerialNumber) Like "*" & [forms]![zzMAINFORM]![txtSerial] &
"*") AND ((tblProductList.ProductTypeID) Like
[Forms]![zzMAINFORM]![txtFilterProductType] & "*") AND
((tblSiteInformation.CountryID) Like [forms]![zzMAINFORM]![txtCountry]) AND
((tblProductList.DateDeleted) Is Null) AND ((tblServiceReps.ServiceRepID)
Like [Forms]![zzMAINFORM]![txtFilterRep]) AND ((tblProductList.CustomerOrder)
Like [Forms]![zzMAINFORM]![txtFilterOrder] Or (tblProductList.CustomerOrder)
Is Null) AND
((tblProductList.WorkOrder)=IIf([Forms]![zzMAINFORM]![txtFilterWO]="*",(tblProductList.WorkOrder)
Like [Forms]![zzMAINFORM]![txtFilterWO] Or (tblProductList.WorkOrder) Is
Null,(tblProductList.WorkOrder) Like [Forms]![zzMAINFORM]![txtFilterWO])))
ORDER BY Nz([CompanyName]," "), tblSiteInformation.SiteCommonName,
subtblCountry.Country, tblProductList.SerialNumber;
the problem is that access returns a too complex error.
is there any other way i can do what i am attempting?