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

    Query Results on an 'as at' date

    Hello,



    I have a query set up that shows a list of projects and the number of hours allocated to them. It also includes a time remaining field that subtracts the hours used in all of the tasks associated with this project.

    Now, what I want to do is to edit the query so that any given date can be supplied and the results are calculated 'as at' that date.

    A project may currently display 8 hours allocated with 1 hour remaining, but if I search 'as at' last week, the hours remaining may be 2 if an hours work has been done this week. Is this easy to configure? There is a field in every task called DateOfTask so I'm guessing I need to use this but just not sure how to set it up.

    The SQL of the query is currently:
    Code:
    SELECT [TimeSpent Sum].SumOfTimeSpent, Client.ClientIdentifier, Client.Organisation, Service.ServiceType, Service.RetainedHours, Project.ProjectStatus, Project.HoursAllocated, Project.Rate, Project.RateType, [AdditionalHours Sum].SumOfAdditionalHours, [hoursallocated]-[sumoftimespent]+[sumofadditionalhours] AS OverallRemaining, Project.ProjectStatus, Client.ClientStatus
    FROM (Client INNER JOIN Service ON (Client.ClientIdentifier = Service.ClientIdentifier) AND (Client.ClientIdentifier = Service.ClientIdentifier)) INNER JOIN ([AdditionalHours Sum] RIGHT JOIN ([TimeSpent Sum] RIGHT JOIN Project ON [TimeSpent Sum].Project_ProjectID = Project.ProjectID) ON [AdditionalHours Sum].Project_ProjectID = Project.ProjectID) ON (Service.ServiceID = Project.ServiceID) AND (Service.ServiceID = Project.ServiceID)
    WHERE (((Service.ServiceType)="Required" Or (Service.ServiceType)="Documentation") AND ((Project.ProjectStatus)="Live"));
    Thanks!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Give the date and only sum the hrs up to that date.

    select [project], sum([hrs]) as HrsUsed where [date]<=#" & forms!frmMain!txtDate & "#"

  3. #3
    roarcrm is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Posts
    27
    Quote Originally Posted by ranman256 View Post
    Give the date and only sum the hrs up to that date.

    select [project], sum([hrs]) as HrsUsed where [date]<=#" & forms!frmMain!txtDate & "#"
    Tried to include the project date but now the results show a line for every task rather than each project. SQL now looks like:

    Code:
    SELECT [TimeSpent Sum].SumOfTimeSpent, Client.ClientIdentifier, Client.Organisation, Service.ServiceType, Service.MonthlyRetainedHours, Project.ProjectStatus, Project.HoursAllocated, Project.Rate, Project.RateType, [AdditionalHours Sum].SumOfAdditionalHours, [hoursallocated]-[sumoftimespent]+[sumofadditionalhours] AS OverallRemaining, Project.ProjectStatus, Client.ClientStatus, Task.DateOfTaskFROM ((Client INNER JOIN Service ON (Client.ClientIdentifier=Service.ClientIdentifier) AND (Client.ClientIdentifier=Service.ClientIdentifier)) INNER JOIN ([AdditionalHours Sum] RIGHT JOIN ([TimeSpent Sum] INNER JOIN Project ON [TimeSpent Sum].Project_ProjectID=Project.ProjectID) ON [AdditionalHours Sum].Project_ProjectID=Project.ProjectID) ON (Service.ServiceID=Project.ServiceID) AND (Service.ServiceID=Project.ServiceID)) INNER JOIN Task ON (Task.ProjectID=Project.ProjectID) AND (Project.ProjectID=Task.ProjectID)
    WHERE (((Service.ServiceType)="COMPLY As Required" Or (Service.ServiceType)="Comply Documentation") And ((Project.ProjectStatus)="Live Work") And ((Task.DateOfTask)<=Forms![COMPLY As Required Search]!StartDate));

  4. #4
    roarcrm is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Posts
    27
    Still struggling with this one, the query is currently returning a result for each task where I want just a result for each project. Can anybody help?

    SQL is:

    SELECT [TimeSpent Sum].SumOfTimeSpent, Client.ClientIdentifier, Client.Organisation, Service.ServiceType, Service.MonthlyRetainedHours, Project.ProjectStatus, Project.HoursAllocated, Project.Rate, Project.RateType, [AdditionalHours Sum].SumOfAdditionalHours, [hoursallocated]-[sumoftimespent]+[sumofadditionalhours] AS OverallRemaining, Project.ProjectStatus, Client.ClientStatus, Task.DateOfTask

    FROM ((Client INNER JOIN Service ON (Client.ClientIdentifier=Service.ClientIdentifier) AND (Client.ClientIdentifier=Service.ClientIdentifier) ) INNER JOIN ([AdditionalHours Sum] RIGHT JOIN ([TimeSpent Sum] RIGHT JOIN Project ON [TimeSpent Sum].Project_ProjectID=Project.ProjectID) ON [AdditionalHours Sum].Project_ProjectID=Project.ProjectID) ON (Service.ServiceID=Project.ServiceID) AND (Service.ServiceID=Project.ServiceID)) LEFT JOIN Task ON (Task.ProjectID=Project.ProjectID) AND (Project.ProjectID=Task.ProjectID)
    WHERE (((Service.ServiceType)="COMPLY As Required" Or (Service.ServiceType)="Comply Documentation") And ((Project.ProjectStatus)="Live Work") And ((Task.DateOfTask)<=Forms![COMPLY As Required Search]!StartDate));


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

Similar Threads

  1. Replies: 7
    Last Post: 01-21-2014, 11:35 AM
  2. Replies: 1
    Last Post: 02-05-2013, 12:15 PM
  3. Replies: 3
    Last Post: 07-13-2012, 09:18 AM
  4. Replies: 6
    Last Post: 05-14-2012, 07:24 AM
  5. Replies: 4
    Last Post: 03-23-2012, 01:18 PM

Tags for this Thread

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