[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4491
  • Last Modified:

Weekly/Monthly Reports in Access

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
artgal
Asked:
artgal
1 Solution
 
Arthur_WoodCommented:
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
 
artgalAuthor Commented:
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
 
VellenawethCommented:
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
 
Arthur_WoodCommented:
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
 
nathanielSystem Applications DeveloperCommented:
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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now