OK, if I'm understanding correctly, try this code:
Private Sub Form_Current()
Dim lngDays As Long
lngDays = Abs(DateDiff("d", DateAdd("yyyy", 1, Me.txtVoid), Date))
Debug.Print lngDays
Select Case lngDays
Case 1 To 7
MsgBox "Your membership will expire in " & _
lngDays & " day" & _
IIf(lngDays = 1, "", "s"), _
vbOK, "Membership Is Expiring"
Case Is <= 0
MsgBox "Membership Expired", vbOK, _
"Expired Membership"
End Select
End Sub
You may find some use from a function that I've written that returns the
next date for an annual, recurring date:
AdjustDateToOneYearWindow
http://www.accessmvp.com/KDSnell/VBA_Functions.htm#AdjDateWindow
If you put the above function in a regular module, then the code could be
changed to this:
Private Sub Form_Current()
Dim lngDays As Long
lngDays = Abs(DateDiff("d", AdjustDateToOneYearWindow(Me.txtVoid), Date))
Debug.Print lngDays
Select Case lngDays
Case 1 To 7
MsgBox "Your membership will expire in " & _
lngDays & " day" & _
IIf(lngDays = 1, "", "s"), _
vbOK, "Membership Is Expiring"
Case Is <= 0
MsgBox "Membership Expired", vbOK, _
"Expired Membership"
End Select
End Sub
--
Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/
Keypad said:
Ken,
So my thinking was if a one year membership was made today on 5/25/09 then
it would expire on 5/25/2010 right. So then the count would begin on
5/18/2010 which would be 7 days before the membership expires. I'm
thinking
in terms of there being 365 days in a year.
So, as a test I changed my system date to 5/25/2010 and plugged 5/18/2009
into my text control named txtVoid. Then I put a (Debug.Print lngDays)
line
in the section where the code executes and it spit out -365. Is that
correct? Shouldn't it be more like 358. What am I missing?
Here's the code I'm using:
Private Sub Form_Current()
Dim lngDays As Long
lngDays = DateDiff("d", Date, Me.txtVoid)
Debug.Print lngDays
Select Case lngDays
Case 1 To 7
MsgBox "Your membership will expire in " & _
lngDays & " day" & _
IIf(lngDays = 1, "", "s"), _
vbOK, "Membership Is Expiring"
Case Is <= 0
MsgBox "Membership Expired", vbOK, _
"Expired Membership"
End Select
End Sub