Hello Duan and Mr. Viescas
Here I include the sample query and the report output format. What I've been trying to archieve is to count how many department that an individual company has. For example, Company A has only 1 depatment, so the Depatment Count is 1. And both Companies B and C have 2 depatments, therefore the Department Count for each company is 2.
By adding a textbox name: txtDepCount, Control Source: = 1, Running Sum: Over All in the Department Header, and add another textbox to the Report Footer, Control Source: = txtDepCount, that will give the correct count of Total Departments (the grand total)in the Reprt Footer.
However, placing a textbox in the Department Footer with the Control Source:
=DCount("DepID","Company","Company.ComID = 'Department.ComID'") the count becomes 0 (zero). What caused that trouble?
Note: the ComID is Text Type, not Number.
Phucon
the query
SELECT Company.ComID, Company.ComName, Department.DepID, Department.ComID, Employee.EmpID, Employee.EmpFirst, Employee.EmpLast
FROM (Company INNER JOIN Department ON Company.ComID = Department.ComID) INNER JOIN Employee ON Department.DepID = Employee.DepID
ORDER BY Company.ComName;
the report output format
Company: A
Department:A01
Employee: Fisrt Last
xxxxxxxxxxxx xxxxxxxxxxxx
xxxxxxxxxxxx xxxxxxxxxxxx
xxxxxxxxxxxx xxxxxxxxxxxx
Department Count = 1
----------------------------------------------------------------------------
Company: B
Department:B01
Employee: Fisrt Last
xxxxxxxxxxxx xxxxxxxxxxxx
xxxxxxxxxxxx xxxxxxxxxxxx
xxxxxxxxxxxx xxxxxxxxxxxx
Department:B02
Employee: Fisrt Last
xxxxxxxxxxxx xxxxxxxxxxxx
xxxxxxxxxxxx xxxxxxxxxxxx
xxxxxxxxxxxx xxxxxxxxxxxx
xxxxxxxxxxxx xxxxxxxxxxxx
xxxxxxxxxxxx xxxxxxxxxxxx
xxxxxxxxxxxx xxxxxxxxxxxx
Department Count = 2
----------------------------------------------------------------------------
Company: C
Department:C01
Employee: Fisrt Last
xxxxxxxxxxxx xxxxxxxxxxxx
xxxxxxxxxxxx xxxxxxxxxxxx
xxxxxxxxxxxx xxxxxxxxxxxx
Department:C02
Employee: Fisrt Last
xxxxxxxxxxxx xxxxxxxxxxxx
xxxxxxxxxxxx xxxxxxxxxxxx
xxxxxxxxxxxx xxxxxxxxxxxx
Department Count = 2
----------------------------------------------------------------------------
Total Departments = 5
Tidak ada komentar:
Posting Komentar