Solved

report help

Posted on 2004-08-24
8
220 Views
Last Modified: 2008-03-06
I have created the following query from two tables.

SELECT DISTINCTROW DatesMonth.Month, DatesMonth.Week, [Inventory db].TransType, [Inventory db].ItemName, Sum([Inventory db].Quantity) AS [Sum Of Quantity]
FROM [Inventory db] INNER JOIN DatesMonth ON [Inventory db].Date=DatesMonth.Date
GROUP BY DatesMonth.Month, DatesMonth.Week, [Inventory db].TransType, [Inventory db].ItemName;

I am trying to create a report to show the following information this format but am unsure how to do it.

Month October
  Week Number 3

                    Product Name                          Item Reciept (TransType)            Item Fulfillment (TransType)
                    Product A                                          30 (sum of quantity)                    20 (sum of quantity)
                    Product B                                          20                                               5
                    Total                                                 50                                             25

Week Number 4

                    Product Name                          Item Reciept (TransType)            Item Fulfillment (TransType)
                    Product A                                          20 (sum of quantity)                    5 (sum of quantity)
                    Product B                                          30                                              20
                    Total                                                 50                                             25


The tables I have are:

Inventory db:
ID      (primary key)
Date
TransType
ItemName (name of product)
Quantity


DatesMonth
Date (dates from 0ct 03 to dec 09)
Week (cooresponding week number)
Month (cooresponding month)
0
Comment
Question by:cacique1506
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
8 Comments
 
LVL 44

Expert Comment

by:GRayL
ID: 11884907
You do not need the table DatesMonths. By using the [Inventory db].Date and the format function you can generate all the report group headings you desire:

Format([Inventory db].Date,"mmmm") will give you the month name
Format([Inventory db].Date,"w") will give you the week of the month
Format([Inventory db].Date,"ww") will give you the week of the year

Rewrite your query using these functions in place of the reference to week and month in the join table.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 11884955
As to naming conventions, try to avoid the use of spaces in table and field names. Never use Access reserved word such as Date for field and variable names. InventoryDB is just as informative as [Inventory db] and a lot easier to type. If you ever use the field name Date in a query without the table qualifier, you are in for a surprise. InvDate or StkDate but never Date.
0
 

Author Comment

by:cacique1506
ID: 11885848
Thanks for helping me cleaning this up.  I made the changes but i'm not so proficient at access so I've done something wrong the error I get is the Select Statement includes a reversed word or argument name that is misspelled or missing or punction is incorrect.

Here is what I entered.  I also removed the space on Inventorydb

SELECT DISTINCTROW [Inventory db].TransType, [Inventory db].ItemName, Sum([Inventory db].Quantity) AS [Sum Of Quantity]
Format([Inventorydb].Date,"ww")
Format([Inventorydb].Date,"w")
Format([Inventorydb].Date,"mmmm")
Fromat( [Inventory db].TransType, [Inventory db].ItemName);

Could you take a look?  thanks.

0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 44

Accepted Solution

by:
GRayL earned 180 total points
ID: 11887090
You're getting close:

SELECT DISTINCTROW [Inventory db].TransType, [Inventory db].ItemName, Sum([Inventory db].Quantity) AS [Sum Of Quantity]
Format([Inventorydb].Date,"ww")
Format([Inventorydb].Date,"w")
Format([Inventorydb].Date,"mmmm")
Fromat( [Inventory db].TransType, [Inventory db].ItemName);

Becomes:

SELECT DISTINCTROW [Inventory db].TransType, [Inventory db].ItemName, Sum([Inventory db].Quantity) AS [Sum Of Quantity],
Format([Inventorydb].Date,"ww") as WkOfYr,
Format([Inventorydb].Date,"w") as WkOfMon,
Format([Inventorydb].Date,"mmmm") as Month,
Fromat( [Inventory db].TransType, [Inventory db].ItemName);

Remember all fields have to be comma delimited and you should name them to avoid Exp1, Exp2, etc.

The more I think of this the more I believe you do not even need a query. In the textbox of the report group header where you had the month name you could enter:

=format(Inventorydb.InvDate,"mmmm")

Similarly for the week, in a lower groupheader:

=format(Inventorydb.InvDate,"w")

Then in the subgroup footer:

=sum(Inventorydb.Quantity)

Similarly in the group footer and report footer.

Take a look at the reports in the sample database that came with Access - Northwind.mdb.  Those examples are full of neat tricks to help you create professional looking reports.  
0
 

Author Comment

by:cacique1506
ID: 11887234
First Option:
I put this in:
SELECT DISTINCTROW [Inventory db].TransType, [Inventory db].ItemName, Sum([Inventory db].Quantity) AS [Sum Of Quantity],
Format([Inventorydb].Date,"ww") as WkOfYr,
Format([Inventorydb].Date,"w") as WkOfMon,
Format([Inventorydb].Date,"mmmm") as Month,
Fromat( [Inventory db].TransType, [Inventory db].ItemName);

And go "undefined function 'format' in expresion.  What does this mean and how may I be able to correct it?  Thanks.


The Second Option gave me:
Query Imput must contain at least one query or table.  I tried changing the control sources for the three points you posted but I must be doing something wrong.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 11892179
You typed Fromat. I do not believe you want that in the last line. Remove the mispelled word and the parentheses around the last two fields.

Fromat( [Inventory db].TransType, [Inventory db].ItemName);

Becomes:

[Inventory db].TransType, [Inventory db].ItemName;
0
 
LVL 44

Expert Comment

by:GRayL
ID: 11892194
Sorry, you should also get rid of that @#$% space in the table name.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 12262486
Thanks, glad I could help - I think (B?)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question