Display all records

skwilliams

Registered User.
Local time
Today, 16:50
Joined
Jan 18, 2002
Messages
516
I have a main table "tblEmp" with a list of all employees. I also have a table "tblReprints" with individual errors detailed by person. Not every employee will have errors. I would like to run a query to display all employees and their errors.

For example:
tblEmp contains Name1, Name2, Name3 and Name4

tblReprints contains 2 records (errors) for Name1 and 1 record (error) for Name2.

The query would display something like this:
Employee Errors
Name1 2
Name2 1
Name3 0
Name4 0

If an employee doesn't have any errors, the query would display 0
 
If you are wanting to print all employees, I would use a man report to print the list. I would use a sub report to print the any related records that exist.

TIP: To see if a sub report has data, use the .HasData property of the sub report control
 
The query will look something like
SELECT tblEmp.Name,NZ(Count(tblReprints.Error),0)
FROM tblEmp LEFT OUTER JOIN tblReprints
ON tblEmp.Name=tblReprints.Name
GROUP BY tblEmp.Name
 

Users who are viewing this thread

Back
Top Bottom