Running Sum For Time And Group?

Apr 11, 2007

Hello,

I'm trying to calculate some running sum queries in preparation for some charts on a report.

I have:
tbl: Spencerdaily
fld1:datein
fld2:milesdriven
fld3:vehiclenumberdaily

I am trying to calculate the running sum of milesdriven for each year per vehicle. If I use the following I get the same set of sums repeated for each vehicle:

SELECT spencerdaily.VehicleNumberDaily, DatePart("yyyy",[datein]) AS [Year], DSum("milesdriven","spencerdaily","DatePart('yyyy', [datein])<=" & [Year]) AS Mileage
FROM spencerdaily
GROUP BY spencerdaily.VehicleNumberDaily, DatePart("yyyy",[datein])
HAVING (((DatePart("yyyy",[datein]))>2001))
ORDER BY spencerdaily.VehicleNumberDaily, DatePart("yyyy",[datein]);


I tried this but it didn't work:

SELECT spencerdaily.VehicleNumberDaily, spencerdaily.VehicleNumberDaily AS vehiclealias, DatePart("yyyy",[datein]) AS [Year], DSum("milesdriven","spencerdaily","DatePart('yyyy', [datein])<=" & [Year] & " AND [vehiclenumberdaily]<=" & [vehiclealias] & " ") AS Mileage
FROM spencerdaily
GROUP BY spencerdaily.VehicleNumberDaily, spencerdaily.VehicleNumberDaily, DatePart("yyyy",[datein])
HAVING (((DatePart("yyyy",[datein]))>2001))
ORDER BY spencerdaily.VehicleNumberDaily, spencerdaily.VehicleNumberDaily, DatePart("yyyy",[datein]);


What am I doing wrong?

Thanks,
Gifford

View Replies


ADVERTISEMENT

Queries :: Running Count Within Group

Sep 15, 2014

I have data like so:

Code:
SubjectID VisitID
1 5
1 5
2 7
2 7
2 9
2 9
etc

And need to return a running count for the number of visits per subject, so:

Code:
SubjectID VisitID VisitCount
1 5 1
1 5 1
2 7 1
2 7 1
2 9 2
2 9 2
etc.

I'd like to use DCount and have tried all variations of the following, but none of them returns the correct number:

VisitNumber: DCount("*","mytable","VisitID >= " & [VisitID] & " AND SubjectID =" & [SubjectID])

View 4 Replies View Related

Queries :: Running Count Over Group In Query

Feb 2, 2015

I have an access query named "leaveapp" and I want a running count as below:

EmpID TypeID
360 1
360 1
360 14
360 14
360 8
1390 8
1390 8
1390 14
1390 14
1390 1

and i need a column in the right with running count like below

EmpID TypeID runningcount
360 1 1
360 1 2
360 14 1
360 14 2
360 8 1
1390 8 1
1390 8 2
1390 14 1
1390 14 2
1390 1 1

View 3 Replies View Related

Queries :: Running Count Over Group In Query

May 11, 2014

I want to do something within Access 2010, but unfortunately I have only partly succeeded so far..

So far this thread has been very useful: [URL] ....

It (almost) completely explains my problem. I have a database with suppliers that participated in tenders. Now I would like to, on a chronological basis, make a "running count" on how often a supplier participated in these tenders (on the basis of supplierID).

In the attachment you can see an example of how the data in my table looks like. With the following function, which I got out of the thread above, I have already been able to make a running count on how often a supplier participated (its "experience").

The function:
DCount("*";"[Table1]";"Supplier_ID = " & [Supplier_ID] & " AND ID <= " & [ID])

So far, so good. But I would like to go for an extra addition, since now the period on which this running count is based is the entire data set, which runs from 2006 till 2013. In other words, Access starts counting from the first record and ends at record 300.000. What I would like to do is to base this running count on the two years before (and including) the tender's Decision_Date, which is also in the dataset.

Example: a specific supplier participated in a tender that took place on 10 december 2010. Know I would like to know its "experience" with tenders, by means of a running count, based on the period from 10 december 2008 till 10 december 2010.

View 5 Replies View Related

Queries :: Running Count In A Query By Group - Error In Ranking Column Result

Mar 16, 2013

Query is based on 1 table" tblTimeCnv_AgeGroups

Fields:
AgeGroup Time Ranking
30-& under 11.22 1
30-& under 10.41 2
30-& under 9.22 3
30-39 11.32 1
30-39 9.53 2
30-39 9.34 3
30-39 9.30 4

See attachment

My Ranking field is:
Ranking: DCount("*","[tblTimeCNV_AgeGroups]","[AgeGroup]=" & [AgeGroup] & " and time <= " & [time])

In the Ranking column the result is: #error in the first 3 rows then zeroes

View 3 Replies View Related

Running Time Total

Oct 13, 2004

I am trying to put together this report where I can see how many hours the printers were running in a month's time. The sum property for this is working up until it reaches 24 hours then it starts all over again. How can I get it to keep adding hours when it gets to 24?

For example: 20:35 + 6:25 = 3:00

learnasugo

View 3 Replies View Related

Running A Procedure Based On Time

Jan 6, 2005

Hi

How do you run a procedure that activates at a set time?
I want to run a procedure that moves a log file to an archive directory at midnight (or at anytime after this when the PC is next turned on).
Thanks for any help...
Mat

View 1 Replies View Related

Why Is Access Running A Query 2 Time's Before It Get's Results

Sep 28, 2005

Good morning,

I am having some kind of problem. A query in Acces that is used to find results in the DB is asking 2 time's te input.

And there is no way that the input boxes is asking to do this twice..

here is the Query,


SELECT tblHotlines.Hotlinenummer, tblHotlines.Vestigingsnummer, tblDealers.Postcode, tblHotlines.Datum_hotline, tblBestellingen.Chassisnummer, tblBestellingen.Onderdeelnummer, tblBestellingen.[Uitleverings datum], tblBestellingen.[Vervangende auto ingezet?]
FROM (tblHotlines LEFT JOIN tblBestellingen ON tblHotlines.Hotlinenummer = tblBestellingen.Hotlinenummer) LEFT JOIN tblDealers ON tblHotlines.Vestigingsnummer = tblDealers.Vestigingsnummer
WHERE (((tblHotlines.Vestigingsnummer) Like [Geef het vestigingsnummer op] & "*") AND ((tblDealers.Postcode) Like [geef evt een gedeelte van de postcode:] & "*") AND ((tblHotlines.Datum_hotline) Like [Geef de datum op:] & "*") AND ((tblBestellingen.Chassisnummer) Like [Geef het chassisnr op:] & "*") AND ((tblBestellingen.Onderdeelnummer) Like [geef evt het onderdeelnr op] & "*"));

Qhat could be the problem that Access is running a Query twice before getting results

View 1 Replies View Related

Group By Time Error

Jun 21, 2007

I am attempting to set up a query which will perform aggregate functions on records from two fields (Speed, Volume) and group them by a time field (SensorTime). This should essentially result in several months of data being combined into a succint 24-hr time period, divided into 288 five-minute intervals.

The problem is that Access will group some of the time values together, but not others. After some detective work I discovered that many of the times that APPEAR to be equal are actually different values when carried out to the 15th decimal point. I learned that this is a result of rounding error within Excel, from whence I originally imported the data.

My question is: can I apply a ROUND function to times in the original table, thereby solving the problem in all the resulting queries (and if so, how)? Or will I need to round the time values in each individual query (this would take some time)? Or is there a better way to equalize these time values that I'm not aware of? I know Excel has a "Precision as displayed" option but I couldn't find anything similar in Access.

Eagerly awaiting advice!

-Bratlien

View 5 Replies View Related

Change Logon Info At Running Time(using Ms Access)

Feb 28, 2007

hi there,
I'd like to ask the solution for my problem.
I made a new project using ms access 2003,crystal report 9, and visual studio 2005.

I just made a simple access dbase with 1 table(Table 1) and protected with password, o I forgot this table has 2 field(id and desc).
After that I made simple report that using DAO connectivity(save data with report option is disabled).

At last I made simple program(windows app) using visual studio 2005.
I put the CrystalReportViewer component, and these is the code :


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace prj
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void crystalReportViewer1_Load(object sender, EventArgs e)
{

}

private void Form1_Load(object sender, EventArgs e)
{
crystalReportViewer1.ReportSource = System.Environment.CurrentDirectory + "\Report1.rpt";
crystalReportViewer1.LogOnInfo[0].ConnectionInfo.UserID = "Admin";
crystalReportViewer1.LogOnInfo[0].ConnectionInfo.Password = "12";
crystalReportViewer1.LogOnInfo[0].ConnectionInfo.DatabaseName = System.Environment.CurrentDirectory + "\db.mdb";
crystalReportViewer1.LogOnInfo[0].ConnectionInfo.ServerName = System.Environment.CurrentDirectory + "\db.mdb";
}
}
}


and the problem is when I move the access database file to other location, the viewer shows a box to be confirmed by my UserID and password,
my question is how must I write in the program so that the box doesnt come out.

thanks

View 1 Replies View Related

Problem With GROUP BY [Date Time]

Aug 30, 2007

Hi there,

I have a table called tblTransactions with columns called (among others) [Date Time], Ticker, Quantity, Price and Commission. Column [Date Time] contains both a date and a time.
I want to determine the commission paid per day. If I use the following code I still get all single trades on a day as the times at which the trades were exucuted are all different. Is it possible to group by full days only without having to change my database in order to determine the daily commission paid?


SELECT T.[Date Time], sum(Commission) AS TotalCommission
tblTransactions AS T
WHERE T.[Date Time]<=#04/17/07#
GROUP BY T.[Date Time];


Best regards,
JapanFreak

View 4 Replies View Related

Determining Actual Running Time Of External Application In Access

May 3, 2014

I want to run an external application (a batch file) ... and want to run it by clicking on a command button on a form. That part is all fine, using the Shell command. I can determine the start time of the application (also fine with now() function) .. but want to find out how long the external application ran and log that "run time" into my database.

The part I don't know about is the .. really the ending time. How do I determine how long the application really ran for / ended ? I imagine I can use datepart to determine the difference in the start and end times. Or would I use a timer control. (but I cannot find the timer control in Access 2010).

View 3 Replies View Related

Group Data Into Arbitrary Time Periods

Oct 18, 2006

I am new to Access and would be very grateful for some adivce on setting up a query.
The data in the table below comes from a photon counter. Both fields are numbers although TIME actually represents seconds.
I need to be able to group the DATA field by arbitrary TIME periods. e.g. to divide the table up into bins of, say, 8.7 seconds length, showing the total accumulated in the DATA field for each successive period of 8.7 seconds.
The tables are about 300,000 records long.
Any help would be much appreciated.

Thanks,

TIME - DATA
285748175.864557 - 100
285748175.874556 - 100
285748175.884556 - 0
285748175.894557 - 100
285748175.904557 - 0
285748175.914556 - 200
285748175.924556 - 300
285748175.934556 - 0

View 7 Replies View Related

Queries :: Group Overnight Shift Time Together For One Date

Oct 24, 2014

I am collecting data every hour on the hour and I would like to group this data according to Shift (A, B and C) by Date. The only problem I am having is- how can I keep the overnight shift together as one date? 10pm - 6am

I was able to do a simple query where I was able to assign an A, B, or C depending on the field with the Short Time format using nested IIF statements. From there I was able to group by shift (A, B, or C) per date. However the C Shift is split up.

Example. Can Sunday October 5th 10pm to Monday October 6th 6am be grouped as one date.

View 2 Replies View Related

Queries :: Count Number Of Tasks - Group By Date / Time In A Query

Aug 14, 2013

I want to count the number of tasks by department by week. I need the time so my date the task was added is formated as a date/time.

I created a query and added the department (twice so that I can group and count), and transaction date. I clicked on totals and added the count function under the department. I added this criteria to the task date: between [start date] and [end date].

Problem is that it's grouping by day and each one is different because all times are different. How do I group these by day and not time?

View 7 Replies View Related

Running Balance As Opposed To Running Total

Mar 14, 2005

Can anyone tell me how to get a running balance on a report. I know how to create a running total, by setting the "running sum" property of a text box to "Over all".

I can't however see how I can adapt this to give a running balance (as in a bank statement for example). Attempts to do so end up in failure!!

Many thanks in advance.
Peter

View 2 Replies View Related

Reports :: Sum Group Items By Specific Item And Hide Details Of Group Summing

May 29, 2015

Despite Google I can't seem to figure this out.

I have some data in a format similar to:

Name / Style / description / speed / distance
john / driver / careful / 80 / 5500
mary / driver / careful / 70 / 7000
pat / racer / reckless / 100 / 6000
anne / driver / careful / 75 / 1000
peter / racer / reckless / 110 / 6500
don / snail / slow / 60 / 6000

I want my report to total by style, without details and to look like:

driver careful 13500
racer reckless 12500
snail slow 6000

How do you get a report to sum the group items by a specific item and to hide the details of that group summing?

View 2 Replies View Related

Reports :: Control Group Expression For Group In Report?

Mar 28, 2013

Is there a way to have an expression in the control source of a text box in a report, that re-starts or is exclusive for every group within the report?

View 5 Replies View Related

Time Format - Short Time Displayed As Medium Time

May 23, 2006

I have an application with a backend db on PC 1, and the same application on PC 2 linked to the backend db on PC 1 via the network.

The link works fine but the time formats are different.

On PC 1 the time format is shortime and displays as it should i.e. in 24 hour clock format

However on PC 2, opening the same database via the network, the time format is still shorttime but when you read the time within the code it comes out in AM/PM format. Also, when the defaul tiem should be #20:00:00# but this changes to #8:00:00 PM#

Weirdly though, when you just open the table, the times are in the correct shorttime format.

Guessing, it must be a setting within the main core of Access 2003 that is different between the 2 instances?

Any ideas?

This screen shot may help:

View 2 Replies View Related

Time Format - Short Time Displayed As Medium Time

May 23, 2006

I have an application with a backend db on PC 1, and the same application on PC 2 linked to the backend db on PC 1 via the network.

The link works fine but the time formats are different.

On PC 1 the time format is shortime and displays as it should i.e. in 24 hour clock format

However on PC 2, opening the same database via the network, the time format is still short time but the format is in AM/PM or medium time.

Guessing, it must be a setting within the main core of Access 2003 that is different between the 2 instances?

Any ideas?

View 1 Replies View Related

Forms :: Option Group - Warn User When Neither Of 2 In Option Group Not Ticked?

Jul 25, 2013

I stumbled upon the Option Group function just yesterday and, happy as a clam, I created a group with 2 options in radio button style. I assigned the values to a field called Registration_Type as the 2 options are "Confirmed Registrants" and "Prospective Attendees".

[Great. That part works well. When I look at the table, a 1 or a 2 is in that field so it's great to know how to control accidental ticking of radio buttons (previous 450 records or so didn't have this option group functionality so one might easily tick one of the buttons. So one part of controlling option group I know I can handle via the table itself for now.]

The challenge is how to ensure the user always ticks one or the other ... I went back to the main table and tested the 'required entry' option for the Registration_Type field but forcing an action like this is not ideal in my mind. The usual error message vagueness for the average user is no good and I don't want to limit the user so much.

Is there a way to simply have a popup come up warning that neither radio button was ticked? Perhaps something linked to the form - i.e., maybe "after update"?? I only learned about attaching code to before and after update on controls a couple of days ago, so not sure if this would be best approach.

Just something to let the user know that nothing has been ticked in the option group as that controls in which of 2 reports the data will show up in so any record not ticked might mean a registrant being left out, which would be rather disastrous <g>.

View 1 Replies View Related

Reports :: Auto Populate Date And Time Every Time Form Is Updated

Nov 8, 2013

I have a database that stores information for lab testing. Each time a tech does a "step" in the test process he logs it in the table, using an input form. There are different categories, for example preparation, testing, analysis, etc, and each of those steps take time. I have the form autopopulate the date and time with NOW() evertime the form is updated. What i want to do is calculate the time it takes to do each in days. I can easily get how many days it was from now since they logged the test, =NOW()-TestDateTime. What I want to do is get the number of days it took to do each step, ie the number of days between each event. Is there a way to do this?

View 3 Replies View Related

Forms :: Add Time Value To Time Data Type SQL Server Field In Access

May 6, 2015

how to be able to enter time in access form the same way as if would be an access table (1p = 1:00 PM; 1.25 = 1:25 AM etc)

View 1 Replies View Related

Reports :: Attendance Database - Show Time In And Time Out For Specific Date

Apr 3, 2014

I have an attendance database and I connect the time attendance machine db to my access db, what i am trying to do is to generate a report that shows the time in and time out for specific date. the type of attendance db is date/time.

Please see the attached screenshot db from attendance machine.

an also some time there is duplicate entry, I need to get the first and the last entry only for specific date.

View 4 Replies View Related

General :: Formatting Time Conversion - Calculated Elapsed Time

Dec 3, 2013

Formatting issue regarding elapsed time calculated using DateDiff().

I understand that you can specify the output value for DateDiff(). In my case I have chosen "n" for minutes. Each result in my query shows the correct calculation in terms of minutes.

[PunchIn] = 11/23/2013 8:11:28 AM
[PunchOut] = 11/23/2013 5:43:30 PM

[ShiftLength] =DateDiff("n", [PunchIn],[PunchOut]) = 572 minutes.

Now when I try to format the result in terms of H:MM (be it in a form or a report) I get varied results. I'll illustrate an example below:

=Format(([ShiftLength]/60),"0") & "." & Format(([ShiftLength] Mod 60),"00") Returns 10.32 Not correct

=Format(([ShiftLength]60),"0") & "." & Format(([ShiftLength] Mod 60),"00") Returns 9.32 This is correct but I need my result to be in the form of a decimal such as my next example

=([ShiftLength]/60) Returns 9.53333333. Getting there but how do I have this result only show two decimal points 9.53?

View 6 Replies View Related

Forms :: Update Time Portion Of Date / Time Field

Aug 29, 2013

I have a date/time text field on a form with the General Date format and a combo box next to it that has sequencial times as the row source (IE. 12:45 AM, 1:00 AM, 1:15 AM, 1:30 AM, ETC.) When the user chooses a time in the combo box, I want the time portion of the text box to be updated with the chosen time in the combo. I have tried a few things but cant seem to get it right.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved