Solved: Perplexing, becuase nothing was wrong with it. Even without the time data, the functions still work as intended. So no date problem after all. Doing tests with static values showed accurate results. The bug has something to do with the code logic keeping the previous time, and it failing to do this one a page change for the first record.
The Problem:
I have a report that uses DateDiff() to compare two date/time fields I pull off a record. My code works just fine... until the report hits a new page. On the new page, only the first record line gets affected by this magical problem. What's stranger still is that the correct values are in the variables. One of the four values decides it doesn't want to be added in. Just once, and just for kicks I assume.
Code in Question:
My RecordSet. It's working fine, but here it is to see the field contents and ordinal orders.
Then it comes to a part where I add these things together to use in the function.Code:[SIZE=2] Set rstTimes = CurrentDb.OpenRecordset("SELECT Start_Time, End_Time, Start_Date, End_Date FROM TimeTable WHERE Start_Date = #" & Me.Start_Date & "# ORDER BY Start_Time")[/SIZE]
Code:Dim dtmStart As Date, dtmEnd As Date
The issue is with dtmStart. Because running the report with MsgBox outputs shows that both of them work fine the whole way through. Then the dtmStart glitches for the first record of a new page. It simply won't add the rstTimes(0).Value to itself. I can actually add a literal and it'll work. (Like + TimeValue(12:00)). I did that just to test it.Code:[SIZE=2] dtmStart = DateValue(rstTimes(2).Value) + TimeValue(rstTimes(0).Value) dtmEnd = DateValue(rstTimes(3).Value) + TimeValue(rstTimes(1).Value)[/SIZE]
The Output:
For that first record of a new page this is what the message boxes show:
Why does it work 30 times, then on a new page not add them together (even though it's not empty) just for the first row, and then go back to working just fine?
If that's just too bizarre, any one have any work arounds? I don't want to reinvent the date/time wheel. >_<
Thanks.
Last edited: