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 2156
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.
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)
-
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...
|
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;...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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
...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
| |