A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Trying to get difference in Meter readings between rows



 
 
Thread Tools Display Modes
  #1  
Old June 8th, 2004, 05:52 PM
Mike S.
external usenet poster
 
Posts: n/a
Default Trying to get difference in Meter readings between rows

I have an equipment repair table called Repair_History.
Each row represents a work order for a particular piece
of equipment. Each row has several columns including
Equipment#, WorkOrder#, Meter and WO_Date. For each
equipment number in the table I need get the interval
meter readings from one work order to next. So I need a
query sorted by equipment that will give the following
fields:
Equipment #, Current_Workorder, Current_Workorder_Date,
Current_Workorder_Meter, Previous_Workorder_Meter,
Meter_Difference.

The first occurance for each Equipment # would have a
blank in it's "Previous_Workorder_Meter" field since it
is the first workorder for that equipment and there is no
previous.

I cannot get Access to pick up the correct previous meter
in my queries. Can anyone help!
Thanks,
Mike
  #2  
Old June 8th, 2004, 07:05 PM
fredg
external usenet poster
 
Posts: n/a
Default Trying to get difference in Meter readings between rows

On Tue, 8 Jun 2004 09:52:15 -0700, Mike S. wrote:

I have an equipment repair table called Repair_History.
Each row represents a work order for a particular piece
of equipment. Each row has several columns including
Equipment#, WorkOrder#, Meter and WO_Date. For each
equipment number in the table I need get the interval
meter readings from one work order to next. So I need a
query sorted by equipment that will give the following
fields:
Equipment #, Current_Workorder, Current_Workorder_Date,
Current_Workorder_Meter, Previous_Workorder_Meter,
Meter_Difference.

The first occurance for each Equipment # would have a
blank in it's "Previous_Workorder_Meter" field since it
is the first workorder for that equipment and there is no
previous.

I cannot get Access to pick up the correct previous meter
in my queries. Can anyone help!
Thanks,
Mike


Here is a similar query that computes miles driven by a fleet of cars.
I'm sure you can adapt it to your needs.

SELECT tblMultiCars.Auto, tblMultiCars.dteDate, tblMultiCars.Mileage,
Abs([Mileage]-DLookUp("Nz([Mileage])","tblMultiCars","[Auto] = '" &
[Auto] & "' and Month([dteDate]) = " & Month([dteDate])+1)) AS
MilesTraveled
FROM tblMultiCars
ORDER BY tblMultiCars.Auto, tblMultiCars.dteDate DESC;


Change the table name to your table name.
Auto should be your Equipment# field (Text datatype), Mileage should
be your Meter reading field, and dteDate is the WorkOrder data..
Change the Order By to sort differently if desired.
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
  #3  
Old June 8th, 2004, 07:05 PM
MGFoster
external usenet poster
 
Posts: n/a
Default Trying to get difference in Meter readings between rows

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


The solution is in this MS KB article:

http://support.microsoft.com:80/supp.../q101/0/81.asp

--
MGFoster:::mgf00 at earthlink decimal-point net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQMX/34echKqOuFEgEQKD1gCfdBWQsMfuF/Ku6Y2riJrd8kQjTYUAoKpd
l5DIHAGLOVcpaPMeesc3ypo8
=IaKb
-----END PGP SIGNATURE-----


Mike S. wrote:
I have an equipment repair table called Repair_History.
Each row represents a work order for a particular piece
of equipment. Each row has several columns including
Equipment#, WorkOrder#, Meter and WO_Date. For each
equipment number in the table I need get the interval
meter readings from one work order to next. So I need a
query sorted by equipment that will give the following
fields:
Equipment #, Current_Workorder, Current_Workorder_Date,
Current_Workorder_Meter, Previous_Workorder_Meter,
Meter_Difference.

The first occurance for each Equipment # would have a
blank in it's "Previous_Workorder_Meter" field since it
is the first workorder for that equipment and there is no
previous.

I cannot get Access to pick up the correct previous meter
in my queries. Can anyone help!
Thanks,
Mike


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:15 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.