Our system has a form SalaryProcessing. A query calculates the correct salaries for one selected month. The user can go back and select any historical month, and it will calculate correct whether there are many deductions or extra earnings involved. On the salary slip there are also Year to date numbers. If the business financial year starts 1 March, and the employee earned salary for longer than a year. If October’s salary is done, it would be 8 months that makes up the Year to Date numbers. The SalaryProcessing form has a button that writes the Journal to the Journal Table. SalaryProcessing also stores the salary records line by line. If the business had 10 employees for the 8 months there will be 80 records in the Salary records table. To set up a query that calculates the Year to Date numbers is easy, and ours work for a long time now.
I would like to learn how to set up a query, that calculates “Year To Date” numbers without records stored. The following is part of our setup.

  1. F03SalaryProcessing is open when salaries is done.
  2. There is a query q01Month, having a field “Financial Year Number for business”. A sub query q04Month02 follows and displays 12 months of the financial year in which the Salarydate falls. If the example is Salary date 31October2018, then we filter it further with a reference from the form. The query will now show months 1March, to 31October, eight records.
  3. There is a query q01employee. Sub query q04Employee05 follows, filtering employees that was employed before the date on the form, and excluding eployees that terminated service before the selected month.
  4. I first see the need to create a query that will have one record each for every employee for every month a salary was earned. I have q04Month02 and q04Employee05 to link. For example if in March there were 6 employees, April 7, May7, June9, 10,10,10,10 there should be 69 records in the needed query.
  5. My sometimes burnt out brain refuse to help me further today, if I can get 69 records in the new query I know how to do the rest. I battle to work out how to include an employee that worked for two months, lets say 1May to 30June. This query to serve the salary slips YTD numbers does not need to include an employee that worked for two months only, but I will want to set up a report that prints those records for any Startdate to Enddate.



Click image for larger version. 

Name:	YTD01.png 
Views:	14 
Size:	39.7 KB 
ID:	41654Click image for larger version. 

Name:	YTD02.png 
Views:	13 
Size:	24.8 KB 
ID:	41655