Results 1 to 4 of 4
  1. #1
    jlb4350 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Posts
    1

    Automatically change text box based on date changes

    Hello. I have a problem that you all may be able to help me with. I have an access form and on that form are 2 fields, one is called "Status" and the other "Date Last Reviewed".

    What I would like to do is have the Status field set as a text box that will automatically change from "Current" to "Review" when the date in the Date Last Reviewed field reaches a specific date.

    For example, when a user inputs that they reviewed the document today, then the Status field changes to "Current". When that date reaches 30 days or older than the current date, the Status field automatically changes to "Review".



    Could someone steer me in the right direction to accomplish this? I'm sure there will need to be some kind of code or expression to make this happen, but I'm at a loss.

    Thanks in advance!

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Hi

    The textbox called "Status" should NOT normally be bound to the field of a table because this is "calculated" data.

    Set the Control Source property of the textbox called "Status" to:
    =IIf(DateDiff("d",Date(),[Date_Last_Reviewed])>=30,"Review","Current")

    The AfterUpdate event of the other textbox called "Date_Last_Reviewed"
    should be as follows
    Code:
     
    Private Sub Date_Last_Reviewed_AfterUpdate()
    Me.Status.Requery
    End Sub
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    khalid's Avatar
    khalid is offline MS-Access Developer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2010
    Location
    Kuwait
    Posts
    244
    Hi and welcome to AF.net,

    So you have a date field on the form which is recorded to current date if someone enter the data and the status become "Current"?
    And when that date is older than 30 days, then the status should change to "Review"?

    If this is the case? then:

    Code:
    Private Sub Form_Current()
    Dim intDay As Integer
    intDay = DateDiff("d", Me.DateFieldOnForm, Date)
    If intDay >= 30 Then
        Me.status.Value = "Review"
    End If
    End Sub
    Hope this help.

  4. #4
    khalid's Avatar
    khalid is offline MS-Access Developer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2010
    Location
    Kuwait
    Posts
    244
    Oops... Bob Fitz already replied

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Trying to Automatically update date within form
    By accesskid in forum Programming
    Replies: 4
    Last Post: 04-26-2011, 07:45 AM
  2. Change linked table reference automatically
    By kjuelfs in forum Access
    Replies: 1
    Last Post: 07-20-2010, 09:14 AM
  3. Replies: 3
    Last Post: 07-05-2010, 10:46 PM
  4. Replies: 1
    Last Post: 01-26-2010, 10:36 PM
  5. Replies: 0
    Last Post: 07-30-2009, 12:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums