Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / September 2006

Tip: Looking for answers? Try searching our database.

Can't sort by expression

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AlienzDDS - 25 Aug 2006 18:41 GMT
The following query is not sorting as required.  I am adding up cases shipped
out within date parameters and would then like to sort by number of cases
descending.  Any help is appreciated.

SELECT Items.Environment, Items.Item, Last(Items.Description) AS
LastOfDescription, Customers.CustomerID, Customers.Name,
nz(Sum(IIf([actualpickupdate]>forms!frmitemmovmtparameters!date1 And
[actualpickupdate]<DateAdd("d",1,Forms!FrmItemMovmtParameters!Date2),[qtycases])),0)
AS CasesOut, Customers.InactiveCust,
nz(Sum(IIf([actualpickupdate]>forms!frmitemmovmtparameters!date1 And
[actualpickupdate]<DateAdd("d",1,Forms!FrmitemmovmtParameters!Date2),[qtypallets])),0) AS PalletsOut
FROM (Customers LEFT JOIN Items ON Customers.CustomerID = Items.CustomerID)
LEFT JOIN (BillsOfLading RIGHT JOIN InventoryCurrent ON
BillsOfLading.BillOfLadingID = InventoryCurrent.BillOfLadingID) ON
Items.ItemID = InventoryCurrent.ItemID
GROUP BY Items.Environment, Items.Item, Customers.CustomerID,
Customers.Name, Customers.InactiveCust
ORDER BY nz(Sum(IIf([actualpickupdate]>forms!frmitemmovmtparameters!date1
And
[actualpickupdate]<DateAdd("d",1,Forms!FrmItemMovmtParameters!Date2),[qtycases])),0) DESC;

Thanks, Alison.
KARL DEWEY - 25 Aug 2006 21:54 GMT
Try omitting --
nz(Sum(IIf([actualpickupdate]>forms!frmitemmovmtparameters!date1 And
[actualpickupdate]<DateAdd("d",1,Forms!FrmitemmovmtParameters!Date2),[qtypallets])),0) AS PalletsOut

> The following query is not sorting as required.  I am adding up cases shipped
> out within date parameters and would then like to sort by number of cases
[quoted text clipped - 18 lines]
>
> Thanks, Alison.
AlienzDDS - 28 Aug 2006 16:29 GMT
Thanks for responding Karl, but that didn't work.  Anyway I need to show the
Pallets out.

Any other ideas?

Thanks

> Try omitting --
> nz(Sum(IIf([actualpickupdate]>forms!frmitemmovmtparameters!date1 And
[quoted text clipped - 22 lines]
> >
> > Thanks, Alison.
AlienzDDS - 28 Aug 2006 16:53 GMT
I have figured out a solution.

I have changed the query to an append query.  Apended to an empty table and
use that table as the data source for the report.

Now I just need to have the code skip over the append query warnings.

Thanks anyway.

> Try omitting --
> nz(Sum(IIf([actualpickupdate]>forms!frmitemmovmtparameters!date1 And
[quoted text clipped - 22 lines]
> >
> > Thanks, Alison.
John Vinson - 28 Aug 2006 17:33 GMT
>I have figured out a solution.
>
>I have changed the query to an append query.  Apended to an empty table and
>use that table as the data source for the report.
>
>Now I just need to have the code skip over the append query warnings.

That's a really ugly solution...

Why not  base another SELECT query on the totals query, and put in an
OrderBy for the calculated field, if you can't get the calculated
field to sort in a single query?

                 John W. Vinson[MVP]
AlienzDDS - 02 Sep 2006 18:01 GMT
Thanks John,

I know it's an ugly solution.  Thanks for your suggestion.  I'll give it a
try.

Ali

> >I have figured out a solution.
> >
[quoted text clipped - 10 lines]
>
>                   John W. Vinson[MVP]    
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.