Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    JayS is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    8

    Tying Yes/No Field to Date Field

    Hey guys,

    I am creating a database for our contracts. Currently the contracts run on a one year cycle. I am creating an "Expired" Yes/No field. I want this field to be tied to my "Exp Date" date field. So when Todays date passes the exp date field, I want the Yes/No field to automatically check YES.

    Is this possible in my main data table without user intervention?

    Also, is it possible to auto-generate a report based off of the said expired yes/no field at the end of each month?



    Hopefully I explained this clear enough. Thanks in advanced.

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    I guess you could make it a calculated field (don't know, don't use them) but why bother? Instead of having a criteria based on the calculated field, you would simply base it on your expirydate field with the same calculation. Plus calculated fields cannot be indexed which can have a significant effect on performance - one of the reasons I don't use them.

  3. #3
    JayS is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    8
    Quote Originally Posted by Ajax View Post
    I guess you could make it a calculated field (don't know, don't use them) but why bother? Instead of having a criteria based on the calculated field, you would simply base it on your expirydate field with the same calculation. Plus calculated fields cannot be indexed which can have a significant effect on performance - one of the reasons I don't use them.
    Thanks Ajax. I will look into calculated fields, as I am unfamiliar. What do you mean by can't be indexed?

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    indexing is a vital part of database design - all fields which are regularly used for filtering/criteria or sorting should be indexed, otherwise the database will be very slow. Not too apparent on small datasets but very noticeable on large datasets - a dataset of say 1m records will take less than a second to filter if indexed and several minutes if not. Calculated fields, by their nature cannot be indexed - in table design you will see the indexing options for each field - except calculated fields and memo fields.

    To understand indexing, take a look at this link https://www.access-programmers.co.uk...d.php?t=291268

  5. #5
    JayS is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    8
    Quote Originally Posted by Ajax View Post
    indexing is a vital part of database design - all fields which are regularly used for filtering/criteria or sorting should be indexed, otherwise the database will be very slow. Not too apparent on small datasets but very noticeable on large datasets - a dataset of say 1m records will take less than a second to filter if indexed and several minutes if not. Calculated fields, by their nature cannot be indexed - in table design you will see the indexing options for each field - except calculated fields and memo fields.

    To understand indexing, take a look at this link https://www.access-programmers.co.uk...d.php?t=291268
    Thanks Ajax.

    Just want to bump this to see if anyone knows how to create a calculated field for this.

    I've tried : IIf( [Exp Date], Date()> , Date<= )

    But that didn't work lol

  6. #6
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    iif( [exp date]<=date(),yes,no)

  7. #7
    JayS is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    8
    Quote Originally Posted by andy49 View Post
    iif( [exp date]<=date(),yes,no)
    Thanks Andy,

    It is saying this expression can not be used in a calculated column

  8. #8
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Try -1 and 0 instead of yes and no


    Sent from my iPhone using Tapatalk

  9. #9
    JayS is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    8
    Quote Originally Posted by andy49 View Post
    Try -1 and 0 instead of yes and no


    Sent from my iPhone using Tapatalk
    Hm, still giving me the cannot be used in a calc column error

  10. #10
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    calculated fields in table have very limited functionality. referencing the Date function is one of them. To see what you can use, use the expression builder

  11. #11
    JayS is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    8
    Quote Originally Posted by Ajax View Post
    calculated fields in table have very limited functionality. referencing the Date function is one of them. To see what you can use, use the expression builder
    Yeah as I was toying with it I noticed it in the expression builder.

    So the best course of action from my research seems to be the Append Query function. Though that is giving me some validation rule errors when I am trying to append.

  12. #12
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Jay could you use a bound control on a form. Then change the value on the form using vba if the right conditions were met?

    This would change the underlying value in the table


    Sent from my iPhone using Tapatalk

  13. #13
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    So the best course of action from my research seems to be the Append Query function
    I must admit I'm struggling to understand why you need to do this anyway since it is as easy to query based on the date field as a yes/no field, or simply include the calculation in the query when required.

    But good luck with your project

  14. #14
    JayS is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    8
    Quote Originally Posted by Ajax View Post
    I must admit I'm struggling to understand why you need to do this anyway since it is as easy to query based on the date field as a yes/no field, or simply include the calculation in the query when required.

    But good luck with your project
    Yes, understood

    Unfortunately I won't be the person who will be managing the database for much longer after it's created, therefore, I am trying to make things as fool proof as possible. So having fields changed without any need for input by office staff keeps it as easy to understand as possible. As I can imagined entries being missed

  15. #15
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    I'd agree with Ajax. Project less likely to go wrong.


    Sent from my iPhone using Tapatalk

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 10-19-2016, 11:11 AM
  2. Replies: 6
    Last Post: 06-26-2015, 08:55 PM
  3. Replies: 20
    Last Post: 01-13-2015, 02:23 PM
  4. Replies: 2
    Last Post: 05-22-2014, 06:11 PM
  5. Replies: 2
    Last Post: 03-31-2012, 07:53 AM

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