Solved

report help

Posted on 2004-08-24
8
216 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
  • 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
 
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
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)

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now