View Single Post
  #4  
Old June 2nd, 2010, 04:05 AM posted to microsoft.public.access
Arvin Meyer [MVP][_2_]
external usenet poster
 
Posts: 2,310
Default Calculate working days between records


"kidkosmo" wrote in message
...

Thanks, Arvin. That does give me an alternative to using the
dhcountworkdaysa function when calculating two dates within the same
records. Where I'm getting stuck, though, is comparing two dates
between consecutive records. Here's what I'm hoping to achieve:

KeyID Date Entered Comment Date Work days since last
comment
1234 1/24/2010 1/24/2010
0 (since it's a new record)
1234 1/24/2010 1/26/2010
2
1234 1/24/2010 1/28/2010
2
12345
5/30/2010 1 (since no
comments were entered, use current date as default)

The sample above appears to be from the same record, but maybe it difficult
to read with newsreader wrapping.

It is possible to do consecutive records, but it will take some time to
write and debug the code to do it. What you will need to do is to build a
recordset of the records that you want to compare, sorted on the field that
you are comparing on. Now start looping through the recordset and take the
first value, and save it to a variable, then subtract the next row of data,
and update or append the result to a table. Then go to the next row after
saving the previous row to the same variable. Just keep looping until you've
finished.

When you get it (it will take a while to debug) please post it back to this
thread.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.accessmvp.com
http://www.mvps.org/access
Co-author: "Access 2010 Solutions", published by Wiley