Results 1 to 2 of 2
  1. #1
    roarcrm is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Posts
    27

    Calculated Field in Query


    Hello,

    I have a form called Project that has a sub-form called Task. Within the task form I have a calculation field to calculate the total time spent in all tasks within the project, the calculation is: =Sum([TimeSpent]). Then, within the project form I have another calculation field to deduct this total from the amount of hours allocated to a project to give the hours remaining - the calculation is: =[HoursAllocated]-[Task].[Form]![TimeSpentCalculationField].

    Now, as these values are calculated on the form they are not in the tables and I need to find a way to use this in queries, e.g. search for projects where hours remaining is less than 10 hours for example.

    What is the best/easiest way to do this for both myself and other users?

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    if you have a form/subform arrangment your tables must follow the same type of arrangment table/subtable (i.e. orders and line items for that order). So the easiest way is to create an aggregate query on your subtable that is sum([TimeSpent]) as one field and the FK of the table as the second field. This will give you the total timespent for each item on the main table.

    Then create a query based on the main table, add the query you just created perform your subtraction in a third field and put the criteria in that third field.

    There are ways to do this as a single query but I prefer the subquery method so I can modify it easily when necessary.

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

Similar Threads

  1. Subtract a Calculated Field with a Query
    By NikkoF in forum Queries
    Replies: 12
    Last Post: 06-22-2014, 11:47 PM
  2. Replies: 2
    Last Post: 05-23-2014, 08:35 PM
  3. Replies: 4
    Last Post: 03-20-2014, 03:52 PM
  4. Calculated field on results in the same query
    By becka11 in forum Queries
    Replies: 1
    Last Post: 05-07-2013, 05:11 PM
  5. Replies: 3
    Last Post: 02-13-2013, 10:15 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