Results 1 to 4 of 4
  1. #1
    KPAW is offline Novice
    Windows Vista Access 2007
    Join Date
    Mar 2011
    Posts
    7

    Auto fill field in a table by comparing a given date against the current date

    I am building a database to track contract of employees so that I can know which contracts are valid and which are expired.



    My table has the following fields:

    ID (Primary key)
    Employee ID (Foreign key to link to the employee table)
    Start_Date
    End_Date
    Status (Either valid or expired)

    Challenge

    I want when I enter the end date, the system checks the end date against the current date and fills in the status field with either valid or expired as appropriate. For instance if the contract end date is March 10,2016, the status must be filled in the word valid.

    Thanks for any assistance

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Are you using a form to input data? if so, then create an =IIF statement; ie. =IIF(End_Date > DAte(), "Valid", "Expired"). Put this in your control for the Status on your form.

  3. #3
    KPAW is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2011
    Posts
    7
    Thanks for the solution, but my intention was not to use a form to input valid or expired.

    Instead, what I want to have happen is that I enter the contract start and end dates, and the system must compare end date against current date and input valid if end_date > Date().

    However, with the passage of time the end_date would be less than current Date, the value in the field should change to expired.

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    It is not advisable to have users enter data directly into tables. There is to much risk to this methodology. Unless your data is coming from an outside (linked) source, you should be entering your data in a form. If you are using linked tables, then you will need to run an update query to change the information in your tables, however experienced Access users will not run calculations in tables, but will run queries and reports with the needed information generated within the query. In that manner, the expired/valid information is updated each time you run the query. It is important to understand that relational databases do not perform as a spreadsheet. That is a different mentality completely.

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

Similar Threads

  1. Replies: 2
    Last Post: 07-07-2014, 09:19 AM
  2. Auto Fill a date in a field
    By SJJ in forum Access
    Replies: 1
    Last Post: 02-17-2014, 02:39 PM
  3. Replies: 3
    Last Post: 12-24-2013, 04:20 PM
  4. Lock field after auto date fill
    By DCV0204 in forum Forms
    Replies: 4
    Last Post: 11-25-2013, 08:53 AM
  5. Comparing Date with current Date
    By ds_8805 in forum Forms
    Replies: 7
    Last Post: 03-31-2010, 09:31 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