What is a Function to Display a String if certain Date is Within Defined Date Range?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jcrist30
    New Member
    • Feb 2012
    • 10

    What is a Function to Display a String if certain Date is Within Defined Date Range?

    I know I have seen this before, but I can't seem to locate the example again.

    What I have is a contracts database, and I am trying to create a field that will display a notification when the current system date is within a certain number of days (i.e. 90 days) of the contract term date.

    The example I have seen had a field (let's say, "Notificati on") in a table ("Contracts" ) that has its default value set to the function so that if the "Contract Term Date" field value is only 60 days away, the "Notificati on" field will populate with a string "Renew Contract", but if it's 100 days away, the "Notificati on" field is null.

    Any insight would be great!
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    It's probably a combination of the IIf() function and the DateDiff() function.

    Comment

    • Mihail
      Contributor
      • Apr 2011
      • 759

      #3
      I think is not necessary to create a field for that.
      More than, I think that is WRONG to create such a field. See here why: http://bytes.com/topic/access/insigh...ble-structures

      If you wish to see that notification in a form or a report then place an unbound text box (lets name it txtContractStat us) in the detail area of your form or report and set the ControlSource like this:
      Code:
      txtContractStatus.ControlSource = IIf(DateDiff("d", Now(), [ContractDateFieldName]) <= 90, "InTime", "OutOfTime")

      Comment

      Working...