473,659 Members | 2,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Building Instant Reports By Date

8 New Member
Hello,

I'm building a tracking tool using Access 2003, where my users will be entering orders that includes quantity of products sold, and cost per unit.

I'm in the process of building several instant reports where they can click on a control without having to specific any criterias such as data ranges and pull up an instant report

What I'm having trouble with is building reports that will compute totals by certain dates (Totals For Last Week, Totals For Last Month) based on the run date.

What is the best way to build a query that will automatically locate a weekly or monthly date range based on the run date
For example: If I run a report today (6/22/2007) for last week's data, I want to write a script to query records between (6/10/2007 - 6/16/2007)
Jun 23 '07 #1
4 2178
ADezii
8,834 Recognized Expert Expert
Hello,

I'm building a tracking tool using Access 2003, where my users will be entering orders that includes quantity of products sold, and cost per unit.

I'm in the process of building several instant reports where they can click on a control without having to specific any criterias such as data ranges and pull up an instant report

What I'm having trouble with is building reports that will compute totals by certain dates (Totals For Last Week, Totals For Last Month) based on the run date.

What is the best way to build a query that will automatically locate a weekly or monthly date range based on the run date
For example: If I run a report today (6/22/2007) for last week's data, I want to write a script to query records between (6/10/2007 - 6/16/2007)
Based on a Run Date of 6/22/2007, the following code will dynamically create a Query based on a ficticious Table which will return all Records between the Range of 6/10/2007 and 6/16/2007 (10 days prior to Run Date to 6 days prior to Run Date). The code makes the hugh assumption that the Run Date is on a Friday and is based on your beginning and ending specifications. Any questions, feel free to ask:
Expand|Select|Wrap|Line Numbers
  1. Dim dteRunDate As Date, dteStartDate As Date
  2. Dim dteEndDate As Date, MySQL As String
  3. Dim MyDB As DAO.Database, qdf As DAO.QueryDef
  4.  
  5. Set MyDB = CurrentDb()
  6.  
  7. For Each qdf In MyDB.QueryDefs
  8.   'Create your own Query Name
  9.   If qdf.Name = "Orders For Date Range" Then
  10.     MyDB.QueryDefs.Delete qdf.Name
  11.   End If
  12. Next
  13.  
  14. dteRunDate = #6/22/2007#
  15. dteStartDate = DateAdd("d", -12, dteRunDate)
  16. dteEndDate = DateAdd("d", 6, dteStartDate)
  17.  
  18. 'substitute your own Table and Field Name 
  19. MySQL = "Select * From tblTableName Where [Your_Date_Field] Between #" & dteStartDate & "# And #" & dteEndDate & "#;"
  20.  
  21. 'if different, must match the Query Name you deleted above
  22. Set qdf = MyDB.CreateQueryDef("Orders For Date Range", MySQL)
  23.  
  24. RefreshDatabaseWindow
  25.  
  26. Set qdf = Nothing
Jun 25 '07 #2
stpark22
8 New Member
Thank you for responding. The issues I have with this method is the following: I don't want to hard code the "run date" because this will frequently change. This will affect the parameters passed to the DateAdd function

dteRunDate = #6/22/2007#
dteStartDate = DateAdd("d", -12, dteRunDate)
dteEndDate = DateAdd("d", 6, dteStartDate)

Also, I rather use the ADO library because I'm running this procedures using data with a SQL Server database and I'm looking to convert this into a web app.
Jun 30 '07 #3
FishVal
2,653 Recognized Expert Specialist
Thank you for responding. The issues I have with this method is the following: I don't want to hard code the "run date" because this will frequently change. This will affect the parameters passed to the DateAdd function

dteRunDate = #6/22/2007#
dteStartDate = DateAdd("d", -12, dteRunDate)
dteEndDate = DateAdd("d", 6, dteStartDate)

Also, I rather use the ADO library because I'm running this procedures using data with a SQL Server database and I'm looking to convert this into a web app.
Try to use the following

Expand|Select|Wrap|Line Numbers
  1. dteStartDate = DateAdd("d", -Weekday(dteRunDate) - 7, dteRunDate)
  2. dteEndDate = DateAdd("d", -Weekday(dteRunDate), dteRunDate)
  3.  
Jun 30 '07 #4
ADezii
8,834 Recognized Expert Expert
Thank you for responding. The issues I have with this method is the following: I don't want to hard code the "run date" because this will frequently change. This will affect the parameters passed to the DateAdd function

dteRunDate = #6/22/2007#
dteStartDate = DateAdd("d", -12, dteRunDate)
dteEndDate = DateAdd("d", 6, dteStartDate)

Also, I rather use the ADO library because I'm running this procedures using data with a SQL Server database and I'm looking to convert this into a web app.
The issues I have with this method is the following: I don't want to hard code the "run date" because this will frequently change.
I rather use the ADO library because I'm running this procedures using data with a SQL Server database and I'm looking to convert this into a web app
  1. The Run Date was hard coded for demo purposes only.
  2. Whether you use DAO or ADO would not effect the basic logic, only the syntax.
Jun 30 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1733
by: PatchFactory Support | last post by:
Description: Professional and easy-to-use patch building environment that can help you to create instant patch packages for software and file updating. Generated patch packages are small size self-extracting executable update programs in a famous installer style with adjustable user-friendly interface and multilingual support. Enhanced with features like easy-to-use interface including a Wizard mode, powerful patch engine, integrated...
0
1800
by: Lynda Kilgore | last post by:
jGu ----qtHwhORV90yyhqJMOc Content-Type: text/html; Content-Transfer-Encoding: quoted-printable <html><head><style type=3Dtext/css>.eyebrow { FONT-WEIGHT: bold; FONT-SIZE= : 10px; TEXT-TRANSFORM: uppercase; COLOR: #ffffff; FONT-FAMILY: verdana,ar= ial,helvetica,sans-serif; TEXT-DECORATION: none } A.eyebrow:link { TEXT-DE= CORATION: none }</style><title>H</title><meta http-equiv=3DContent-Type co=
7
1629
by: SharkSYA | last post by:
After canvassing ideas it appears that the way I need to do it is not possible.There are 126 rooms, more to be added, and it needs to print a report or reports showing 76 days of bookings. There are two queries involved: Here's the code(Thanks Bob Q!) SELECT Calendar.Date, Bookings.room FROM Calendar, Bookings
2
1620
by: Rene | last post by:
I have a master "attendance" report that also has two "attendance" sub-reports...each collecting data from a different group...and totaling those present at the end. I chose sub-reports because of the way they needed the data displayed. When printing this report, they wanted an option to select by date. The sub-reports are linked to the master by this "date" field.
1
2908
by: longtim | last post by:
I have been having endless difficulty creating reports/queries that set any relevent parameters from controls in forms. I am creating an application under access 2003 but will target access 2000. The access file is in access 2000 format. I have a form that will hold the relevent parameters for the query/report that reports the statistics for all job records that match a certain criteria. These are: - A Customer Name.
10
2281
by: jerry.ranch | last post by:
I get extracts/reports from a corporate Sybase database. This is a very very large transactional database, very little (or slow and complex) reports/queries, so instead I have an all-inclusive query run, dropped into a folder each night, and then do my data analysis/mining via Access. Now here's my problem The DATA (stored as a Trait) is not stored in separate fields for each trait .. here's an example
7
3713
by: rzagars | last post by:
I have just started working on DB2 which the syntax is a lot different. I am trying to create a SQL stored procedure for generating reports. I want to use temporary database which in this example it is trult not needed but due to past experience it is key to developing good reports for cliebt/server application. Here is my example which of course dopes not work and documentation on the Internet is limited. Please if anyone can clarify...
3
6522
by: wsox66 | last post by:
I am new to Access and need some help building a report. I have looked through previous posts on reports but none of them seem to answer my question completely. I am using Access 2003 and I have a database with one table. I have built ten different queries to organize run calculations on the records in the table. The problem is that the queries don't all access the same columns nor do they all return the same number of rows and columns in...
4
1540
by: shahidrasul | last post by:
hi i have a object to a user defined class which properly intialized from class when first form load, but after post back it loose reference and such error occured monthlyreport.GetReport() in c:\Time Entry System\WebTimeEntrySystem\monthlyreport.aspx.cs:100 monthlyreport.btn_show_report_Click(Object sender, EventArgs e) in c:\Time Entry System\WebTimeEntrySystem\monthlyreport.aspx.cs:94 ...
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8626
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.