FoxProProgrammer
Programmer
The Query below causes an error.
Here's the error:
"ORDER BY clause (Left([SRU],4)) conflicts with DISTINCT."
The explanation in Help says:
You created an SQL statement with an ALL, DISTINCT, or DISTINCTROW predicate and an ORDER BY clause that contains a field not listed in the SELECT statement. Remove the DISTINCT reserved word, or remove the specified field from the ORDER BY clause.
The field [SRU] is in the SELECT statement, so I don't know what Access doesn't like about this. I use the same ORDER BY clause in another Query that doesn't require the DISTINCT clause, and it works there. I am trying to sort by a field of the form AAASNN, where A is a string, S is a space, and N is a number. If I remove the DISTINCT clause, the Query runs, but there are duplicates in the results.
Thanks for your help!
dz
Code:
SELECT DISTINCT Components.SRUID, SRU.SRU, PartNumbers.PartID
FROM SRU INNER JOIN (PartNumbers INNER JOIN Components ON PartNumbers.PartID = Components.partID) ON SRU.SRUID = Components.SRUID
WHERE (((PartNumbers.PartID)=[lst_PN].[Value]))
ORDER BY Left([SRU],4), Val(IIf(IsNumeric(Mid([SRU],5,1)),Mid([SRU],5),Mid([SRU],4)));
Here's the error:
"ORDER BY clause (Left([SRU],4)) conflicts with DISTINCT."
The explanation in Help says:
You created an SQL statement with an ALL, DISTINCT, or DISTINCTROW predicate and an ORDER BY clause that contains a field not listed in the SELECT statement. Remove the DISTINCT reserved word, or remove the specified field from the ORDER BY clause.
The field [SRU] is in the SELECT statement, so I don't know what Access doesn't like about this. I use the same ORDER BY clause in another Query that doesn't require the DISTINCT clause, and it works there. I am trying to sort by a field of the form AAASNN, where A is a string, S is a space, and N is a number. If I remove the DISTINCT clause, the Query runs, but there are duplicates in the results.
Thanks for your help!
dz