Solved

report help

Posted on 2004-08-24
8
215 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

743 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

13 Experts available now in Live!

Get 1:1 Help Now