Gustav Brock
Gustav at cactus.dk
Wed Jan 23 03:17:35 CST 2008
Hi Mark
Your problem is perhaps that you are casting the poor date time values to and from string values.
Try this:
' Remove a time part and add new time.
RecordDT_end = Fix(rst!Q_DT.Value) + #4:30:00 PM#
RecordDT = Fix(rst!Q_DT.Value) + #9:30:00 AM#)
Do Until RecordDT = RecordDT_end
If RecordDT = RecordDT_end Then MsgBox "yes"
'Inner Loop
RecordDT = DateAdd("n", 30, RecordDT)
Loop
If that still fails, follow the advice from Andy to eliminate rounding errors:
Do Until DateDiff("s", RecordDT, RecordDT_end) = 0
/gustav
>>> markamatte at hotmail.com 23-01-2008 01:05:13 >>>
Hello All,
I am looping thru a recordset...and I need it to stop when it gets to a certain time. I am sure I am missing something simple...below is the code...it FAILS!!!...and I have no clue why...probably very simple...but anyway...any thoughts...even the IF fails...when they appear to be equal????
Dim RecordDT As Date
Dim RecordDT_end As Date
RecordDT_end = CDate(rst!Q_DT & " 4:30:00 PM")
RecordDT = CDate(rst!Q_DT & " 9:30:00 AM")
Do Until RecordDT = RecordDT_end
If RecordDT = RecordDT_end Then MsgBox "yes"
'Inner Loop
RecordDT = CDate(DateAdd("n", 30, RecordDT))
Loop
Thanks,
mark