Problem creating report

This should be simple, but I can’t figure it out. I have a simple report. Department, then Employee connected on Department Code I want to show the employees in each department, sorted by a field that I added, YTD Sales, in descending order. I have made a key on Employee for YTD Sales. Then I want to total YTD Sales for each department. Problem: The report sorts and works correctly if I don’t add either the Createtotals code or use the Total Fields property, but no totals unless I manually add variable and add. When I use createtotals, I show the top record with an amount and only some employees from the department. If I don’t sort, but createtotals, it works correctly, but of course, the records are not sorted, but all records show and totals are correct. What is the problem with creating totals AND sorting?

If you use foreign keys on a master-table, the sub-table must contain the full foreing key of the master table. In other words: The key on Employee Table must be >Department Code,YTD Sales< in this order. Regards Marcus

That makes sense, but how do I sort by Ascending by department and Descending on YTD Sales?

In this case you are right: Your only chance is to create a two-level report: Departments – Employees. The point is that Createtotals doesn’t always work properly in two-level reports. I never figured out under which curcumstances it works or doesnt’ but I suspect that it works if you use the statement CurrReport.Createtotals(YTD) onPreDataItem of the Employee while it does not work if you define it as property. (Correct me if I’m wrong) Sometimes there’s really no other way than accumulating the values manually. Marcus

I thought that the createtotals was causing the problem. I tried accumulating manually, but have to add a footer to employee to show the totals. I guess it is the footer that is causing the problem because I still have a problem. Any suggestions?