HillTJ
To train a dog, first know more than the dog..
- Local time
- Today, 10:15
- Joined
- Apr 1, 2019
- Messages
- 731
Hi all, I'm attempting to write a module that will return one of several warning messages when a training 'Renewal Date' approaches as Renewals are required 3 years after training.
So, I pass the last 'Completion Date' to the function below & add 3 years to it. (I call it 'dteRenewal' in the function for want of a better name).
I then wish to return a warning at 3 months till renewal, 1 month, 1 week & 'Expired' when the Renewal date is < actual date.
Seems I've gotten my wires crossed & would appreciate some guidance.
Thanks in advance.
So, I pass the last 'Completion Date' to the function below & add 3 years to it. (I call it 'dteRenewal' in the function for want of a better name).
I then wish to return a warning at 3 months till renewal, 1 month, 1 week & 'Expired' when the Renewal date is < actual date.
Seems I've gotten my wires crossed & would appreciate some guidance.
Thanks in advance.
Code:
Option Compare Database
Option Explicit
Public Function CalcExpiry(dteRenewal As Date) As String
Const conJetDate = "\#mm\/dd\/yyyy\#"
'system date format is dd/mm/yyyy
MsgBox Format(dteRenewal, conJetDate) ' for testing
MsgBox DateAdd("m", 3, Date) 'for testing
Select Case dteRenewal
Case DateAdd("m", 3, Date) > Format(dteRenewal, conJetDate)
CalcExpiry = "Expires in 3 Months"
MsgBox "3 Months"
Case DateAdd("m", 1, Date) > Format(dteRenewal, conJetDate)
CalcExpiry = "Expires in 1 Month"
Case DateAdd("WW", 1, Date) > Format(dteRenewal, conJetDate)
CalcExpiry = "Expires in 1 Week"
Case Date > Format(dteRenewal, conJetDate)
CalcExpiry = "Expired"
End Select
MsgBox CalcExpiry
End Function