Solved

Weekly/Monthly Reports in Access

Posted on 2004-04-26
5
2,722 Views
1 Endorsement
Last Modified: 2009-07-29
I need to create reports as follows:
Weekly reports all data should pull for the prior week
Monthly reports - all data should pull for the month that the user selects or enters

Could you give me ideas on the best way to do this?  I want it to be automated so they can just select a button - Prior week reports instead of having them enter dates from parameters with a between criteria query.  Thanks so much for your help!!
1
Comment
Question by:artgal
5 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 10921404
when you say weekly, do you mean for the PAST 7 DAYS,no matter when the report is generated, or is this to be Monda through Friday of the week that ended LAST Friday (run on ANY day of the current week)

Same applies to Monthly (the past 30 days), or 1st of Month through End of Month for LAST Month.

AW
0
 

Author Comment

by:artgal
ID: 10921442
I mean it to be a Monday through Friday of the week that ended Last Friday run on Any day of the current week.

Same for Monthly ... 1st of the Month through End of Month for Last month.  

Thanks!
0
 

Expert Comment

by:Vellenaweth
ID: 10921677
Ok, you can do a Master query with a Form. In the form you can put a field which is used as a criteria in the query so it knows if the user wants a Week Report or a Month report.
Lets suppose you use a multiple choice box (I'm sorry English is not my first language and I'm not sure of the technical translation of some of Access objects to English), where 1 is the value for week and 2 is the value for month. Let's suppose you name that field ReportDateFormat
switch(ReportDateFormat=1,cstr(format(DateToBeFormated, "ww / yy")),ReportDateFormat=2,cstr(format(DateToBeFormated, "mm / yy")))

It is important to apply the Cstr because in case you want to be Cross Queries, it won't be able to do it unless you convert the Date to String.

0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 10922057
for the Weekly report:

base it on this query:

Select * from YourTable where Format(YourDateField, "ww/yy") = Format(DateAdd("ww",-1,Date()),"ww/yyyy")

make the necessary changes to table name and field names.

similarly for the Last Month report:

Select * from YourTable where WHERE (((YourDateField,"mm/yyyy"))=Format(DateAdd("m",-1,Date()),"mm/yyyy")))

AW
0
 
LVL 6

Accepted Solution

by:
nathaniel earned 250 total points
ID: 10924552
Hi artgal, here's another idea:


say you have table as : tbl_Transaction
and fields as              : transID, transType, transDate, transAmount


Here are the following reports you may create using Access' Query
(I assume you are already familiar in creating Queries)


Query1: Daily Transactions Summary Report for the Month of February
----------------------------------------------------------------------------------
(Copy-Paste in Query Design -> SQL view)

SELECT Format([transDate],"mmm-dd-yyyy") AS DailyReportForTheMonth, Sum(tbl_Transaction.transAmount) AS SumOftransAmount
FROM tbl_Transaction
WHERE (((Month([transDate]))=2))
GROUP BY Format([transDate],"mmm-dd-yyyy");

Note:
You can ask Month from users by changing WHERE to:
WHERE (((Month([transDate]))=[Enter Month: 1=Jan 2=Feb  12=Dec:]))



Query2: Weekly Transactions Summary Report as of Apr-9 (Cut-off)
------------------------------------------------------------------------------
(Copy-Paste in Query Design -> SQL view)

SELECT Format([transDate],"mmm-dd-yyyy") AS WeeklyReport, Sum(tbl_Transaction.transAmount) AS SumOftransAmount
FROM tbl_Transaction
WHERE (((tbl_Transaction.transDate) Between #4/5/2004# And #4/9/2004#))
GROUP BY Format([transDate],"mmm-dd-yyyy");

Note: above query is a fixed one but if you want your user to enter a cut-off date (say Mon-Friday, Friday is your cut-off day) then you need to create a visual basic function to further automate your query. If you're not ready with vb yet, then here's the other equivalent Queries.

In this example, we will need to create a subquery as follows:


SUBQUERY: To get cut-off date from user:
--------------------------------------------------
(Copy-Paste in Query Design -> SQL view)

SELECT tbl_Transaction.transDate, [Enter Cut-off date (Friday):] AS [Cut-Off], Sum(tbl_Transaction.transAmount) AS TotalAmount
FROM tbl_Transaction
WHERE (((tbl_Transaction.transDate)<=[Enter Cut-off date (Friday):]))
GROUP BY tbl_Transaction.transDate, [Enter Cut-off date (Friday):];

Note: don't run yet. here's the main Query to run..


QUERY2: A parameter query to generate Weekly Report based on User cut-off date:
------------------------------------------------------------------------------------------------
(Copy-Paste in Query Design -> SQL view)

SELECT SubQuery.transDate, SubQuery.[Cut-Off], Sum(SubQuery.TotalAmount) AS SumOfTotalAmount
FROM SubQuery
WHERE (((DateDiff("d",[transdate],[cut-off]))<8))
GROUP BY SubQuery.transDate, SubQuery.[Cut-Off];


Hope my examples above gave you an idea.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Read about achieving the basic levels of HRIS security in the workplace.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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…

744 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

11 Experts available now in Live!

Get 1:1 Help Now