Solved

report help

Posted on 2004-08-24
8
222 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

617 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