Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I posted a query a short while ago and had an informed answer within a couple of hours. Terrific!..."

Geography

Where in the world do Tek-Tips members come from?

Need Help on Query for Orders. 90% Done just cant figure out the last

grippy (Programmer)
9 May 12 15:51
Ok I havent used Access in a while to actually create something so Im trying to make a sales report.  I have two tables:

First Table
 dbo_tblOrders with orderNumber, salesTaxRate, orderShipping, orderTotal, orderDate, shipFirstName and shipLastName

Second Table
dbo_tblOrderDetails with orderNumber, quantity, salePrice

Then in my Query i have to fields I made one which is SubTotal (SUM([quanity] * [salePrice]) from another query and TaxedSubtotal (Sum([salesTaxRate]*[SubTotal])

Now I open the report I made in the wizard and it prompts me for the begin date and end date for the query range and displays all the data fine except for orders that have multiple items then is just displays another row with the same order number and different info.  Here is what its looking like now:

Orders Query_orderNumber, OrderDetails Query_orderNumber,  orderDate, shipFirstName, shipLastName, SubTotal, Taxed Subtotal, orderShipping, orderTotal
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
26550     26550  12/1/11  Bobby McNugget  183.80   14.24   24.95   222.99
26569     26569  12/2/11  Mr Man                103.50   16.04  31.80   434.27
26569     26569  12/2/11  Mr Man                166.52   12.90  31.80   434.27

So basically it should only have one row for each order and be summarized and be displayed as:

26550     26550  12/1/11  Bobby McNugget  183.80   14.24   24.95   222.99
26569     26569  12/2/11  Mr Man                270.02   28.94   31.80   434.27

Let me know how I can fix my query.  Thank you for the help.  Here is my current SQL code on my query:

SELECT [Sales Journal Orders Query].orderDate, [Sales Journal Orders Query].orderNumber AS [Sales Journal Orders Query_orderNumber], [Sales Journal Orders Query].shipFirstName, [Sales Journal Orders Query].shipLastName, [Sales Journal Orders Query].salesTaxRate, [Sales Journal Orders Query].orderShipping, [Sales Journal Orders Query].orderTotal, [Sales Journal OrderDetails Query].orderNumber AS [Sales Journal OrderDetails Query_orderNumber], [Sales Journal OrderDetails Query].SubTotal, Sum([salesTaxRate]*[SubTotal]) AS [Taxed Subtotal]
FROM [Sales Journal Orders Query] INNER JOIN [Sales Journal OrderDetails Query] ON [Sales Journal Orders Query].orderNumber = [Sales Journal OrderDetails Query].orderNumber
GROUP BY [Sales Journal Orders Query].orderDate, [Sales Journal Orders Query].orderNumber, [Sales Journal Orders Query].shipFirstName, [Sales Journal Orders Query].shipLastName, [Sales Journal Orders Query].salesTaxRate, [Sales Journal Orders Query].orderShipping, [Sales Journal Orders Query].orderTotal, [Sales Journal OrderDetails Query].orderNumber, [Sales Journal OrderDetails Query].SubTotal;




 
dhookom (Programmer)
9 May 12 23:36
I would either remove or Sum the column [Sales Journal OrderDetails Query].SubTotal.

You can also use a non-grouped query and use the OrderNumber group header or footer to display the data with no detail section.

Duane
Hook'D on Access
MS Access MVP

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close