DateDiff with Multiple Responses

donbettis

Old User Gone Astray
Local time
Today, 06:14
Joined
Jan 23, 2001
Messages
103
What I am trying to do is this:

If the DateDiff between Today’s Date and a date entered in the NextSchContact field is say <= -90 then I want to put a message in an unbound field called Message. If the DateDiff is <= -180 then I would like a different message to appear…I can make it work by doing = -90 but I am having trouble getting it to work with <=

If I do this the way I can make it work I’d have to put at least 365 different statements in the code…I am trying to avoid this…

How can or can I make it work with “<=“

Here is the code that will work…

Private Sub Form_Current()
Me.Message = DateDiff("d", Date, [NextSchContact])
If Me.Message = -90 Then
Me.Message = "This Customer hasn't been contacted in over 90 days...”
ElseIf Me.Message = -180 Then
Me.Message = "This Customer hasn't been contacted in over 180 days..."
ElseIf Me.Message = -270 Then
Me.Message = "This Customer hasn't been contacted in over 270 days..."
End If
Exit Sub
End Sub


Any and All Help Appreciated
smile.gif



Thanks

Don

Edited Because of Typo...I am starting to get a bad case of Fat Fingers...
smile.gif


[This message has been edited by donbettis (edited 01-07-2002).]
 
Look at the Select Case statement, that should simplify your code considerably.
Code:
Select Case (DateDiff("d",LastContactDate,Now())) 
     Case 0 To 90
          'Do something
     Case 91 To 180
          'Do something else
     Case Else
          'If you need a 'default' value
End Select

Of course, if you don't need the specific categories, but just the value, you could just have Me.Message = "This customer has not been contacted in " & DateDiff("d",LastContactDate,Now()) & " days."

HTH,
David R
 
David R

Thanks Man...It worked like a charm...

I never once thought about using a Select Case Statement... I've used it before but, for whatever reason it never entered my mind...

I guess I had a one of those uhm "blonde moments"! I am entitled to have these moments...I have blonde hair and teenagers...
smile.gif


Thanks For All You Help...

Don
 
No problem. You should see some of the inane questions I asked when I first got here. I knew this one because I used to use Case all the time in C.

Oh, and my condolences on the teenagers. Haven't caught that plague just yet.

David R
 

Users who are viewing this thread

Back
Top Bottom