Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

report help

Posted on 2004-08-24
8
Medium Priority
?
225 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 44

Accepted Solution

by:
GRayL earned 540 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

886 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