Question : Date difference not working on routine

Access 2003 vba

Trying to get a msgbox to pop when a date time limit has expired.

For example:
If today is  Nov 11th 2009

if the date I have entered into the table is 60 prior to  Nov 11th 2009 then a msgbox... So if the date was Aug 1st 2009 in the table  a message box would appear.

I have a splash form.
I have a table called  
timesearch
1 field:  date/time
99/99/0000;0;_    <----   format


Dim rsDate As DAO.Recordset
Dim sd As Date
Set rsDate = CurrentDb.OpenRecordset("timesearch")

If rsDate.RecordCount = 0 Then
    Exit Sub
End If

rsDate.MoveFirst
Do Until rsDate.EOF
    sd = rsDate("fldTime") ' added 09/04/2007
   
    If DateDiff("d", Now(), sd) >= "60" Then
            MsgBox "Your last Update to icart was 60 days from " & Now()
      End If
   
   
    rsDate.MoveNext
Loop
rsDate.Close
Set rsDate = Nothing



Thanks
fordraiders


Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
form load event on the splash form:
 
 
 
Dim rsDate As DAO.Recordset
Dim sd As Date
Set rsDate = CurrentDb.OpenRecordset("timesearch")
 
If rsDate.RecordCount = 0 Then
    Exit Sub
End If
 
rsDate.MoveFirst
Do Until rsDate.EOF
    sd = rsDate("fldTime")     
    If DateDiff("d", Now(), sd) >= "60" Then
            MsgBox "Your last Update was 60 days from " & Now()
      End If
   rsDate.MoveNext
Loop
rsDate.Close
Set rsDate = Nothing

Answer : Date difference not working on routine

change this

  If DateDiff("d", Now(), sd) >= "60" Then

to

  If DateDiff("d",  sd, now()) >= 60 Then
Random Solutions  
 
programming4us programming4us