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)
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: - Dim dteRunDate As Date, dteStartDate As Date
-
Dim dteEndDate As Date, MySQL As String
-
Dim MyDB As DAO.Database, qdf As DAO.QueryDef
-
-
Set MyDB = CurrentDb()
-
-
For Each qdf In MyDB.QueryDefs
-
'Create your own Query Name
-
If qdf.Name = "Orders For Date Range" Then
-
MyDB.QueryDefs.Delete qdf.Name
-
End If
-
Next
-
-
dteRunDate = #6/22/2007#
-
dteStartDate = DateAdd("d", -12, dteRunDate)
-
dteEndDate = DateAdd("d", 6, dteStartDate)
-
-
'substitute your own Table and Field Name
-
MySQL = "Select * From tblTableName Where [Your_Date_Field] Between #" & dteStartDate & "# And #" & dteEndDate & "#;"
-
-
'if different, must match the Query Name you deleted above
-
Set qdf = MyDB.CreateQueryDef("Orders For Date Range", MySQL)
-
-
RefreshDatabaseWindow
-
-
Set qdf = Nothing
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.
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 -
dteStartDate = DateAdd("d", -Weekday(dteRunDate) - 7, dteRunDate)
-
dteEndDate = DateAdd("d", -Weekday(dteRunDate), dteRunDate)
-
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
- The Run Date was hard coded for demo purposes only.
- Whether you use DAO or ADO would not effect the basic logic, only the syntax.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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=
|
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
|
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.
|
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.
| |
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
|
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...
|
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...
|
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
...
|
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...
|
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...
| |
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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |