Results 1 to 13 of 13
  1. #1
    jtm013 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    117

    Trouble with Calculated field.

    Hello,

    I am trying to accomplish what I thought would be simple.


    I currently have a column in my table which lists the date when a tool is due for calibration. I'm trying to create a calculated field which simply determines if the tool is overdue for calibration. In excel this would be a simple matter of comparing the value in the 'due date' field to the current date. However, I have been unable to find a way to do this in access. I'm sure I am overlooking something simple and any assistance is appreciated.

    Thanks,

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What have you tried?


    [due date] = Date()

    or

    [due date] < Date()
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You can do the same thing in Access. To return the current date in a calculated field, use: Date()

  4. #4
    jtm013 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    117
    Quote Originally Posted by June7 View Post
    What have you tried?


    [due date] = Date()

    or

    [due date] < Date()
    I have tried both my field name is toolNextCalDate
    and I have tried both:

    [toolNextCalDate] < Date() and [toolNextCalDate] = Date()

    When I try and save the table it returns the error:

    "The expression [toolnextCalDate]<Date() cannot be used in a calculated column."

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Then can't do in table. Do this in query.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    reentry is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    9
    If i got u right u have to do such a query : The result should be the days since u should have done the calibration. Means if it should be done yesterday the result would be -1 because u are 1 day to late

    Code:
    SELECT [tableName].toolNextCalDate - date() AS Overtime 
    FROM [tableName];
    Or the other way around for the positive numbers 1 day delay

    Code:
    SELECT date() -  [tableName].toolNextCalDate  AS overtime
    FROM [tableName];

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    No, reentry, don't think that is what they are after.

    SELECT * FROM tablename WHERE [due date] < Date();
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    reentry is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    9
    Sry maybe i got him wrong, your Query is perfekt if he wants to get all machines which are over the time. And my query is calculating how much time is left until they have to calibrate or how many days they are over the time.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    True, I guess either would serve. Filter criteria could be applied in your query: <=0
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    jtm013 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    117
    Thanks both for the assistance. However, I already have the capability to run a query to determine if a tool is past its calibration date, using the method described by June7.

    However, I need to be able to store a value of some kind which indicates this on-time/overdue status. So that I can then use that value as a datapoint to generate a dynamic pie chart for the user dashboard. All the pie chart is going to display is percent of total tools on-time/overdue.

    Thanks for the ongoing assistance.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Then use reentry's suggested query to construct a field that calculates a numeric value.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    jtm013 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    117
    June 7-

    I do not believe this would work for instance if we have a total of 10 tools, 3 are over due. I don't need to know that one of the tools is 2 days late another 1 day, etc. I just need to be able to produce a pie chart indicating that 30% of tools are over due and 70% are on time. The specific number of days will be easily seen once the specific record for the tool is selected.

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    SELECT *, IIf([due date] < Date(), "Late", "NotLate") AS Status FROM tablename;

    RowSource for chart:

    SELECT Status, Count(*) FROM Query1 GROUP BY Status;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 2
    Last Post: 12-30-2014, 01:32 PM
  2. Replies: 2
    Last Post: 12-15-2013, 02:29 AM
  3. Replies: 1
    Last Post: 04-21-2013, 03:20 PM
  4. Replies: 3
    Last Post: 02-13-2013, 10:15 AM
  5. Replies: 3
    Last Post: 11-24-2012, 07:33 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