What happens if you open the sub report in design view, paste the filter string (e.g. [EPRproid] In ('1','2')
) into its Filter Property, set Filter On to Yes, and run the sub report as a stand-alone report? Is the report filtered correctly?
I was also wondering about your table structure. I'm assuming one employee can work on several different projects and that each project can have several different employees assigned to it. If you're attempting to model that type of many-to-many relationship, it seems that it would be much easier to dispense with the sub-report altogether, and simply generate a report based on a query that reflects the many-to-many relationship involved (using the reports WhereCondition to filter for individual employees if you like).
What I have in mind is a table schema that looks like:
Schema Key:
PK = Primary Key
FK = Foreign Key
CPK = Composite Primary Key (Primary Key consisting of more than one field)
tblEmployees
-EmployeeID (PK) (AutoNumber)
-EmployeeFirstName (Text)
-EmployeeLastName (Text)
tblProjects
-ProjectID (PK) (AutoNumber)
-ProjectName (Text)
tblEmployeeProjects (Linking Table)
-EmployeeID (CPK)(FK - tblEmployees)(Number)
-ProjectID (CPK)(FK - tblProjects)(Number)
Sample Data:
tblEmplyees
Code:
"EmployeeID" "EmployeeFirstName" "EmployeeLastName"
1 "John" "Doe"
2 "Jane" "Doe"
3 "Jed" "Doe"
tblProjects
Code:
"ProjectID" "ProjectName"
1 "Project1"
2 "Project2"
3 "Project3"
tblEmployeeProjects
Code:
"EmployeeID" "ProjectID"
1 1
1 2
1 3
2 1
2 2
3 1
Using this schema, which is the standard method of implementing a many-to-many relationship in relational databases, you could write a query like:
qryEmployeeProjects
Code:
SELECT e.EmployeeID, EmployeeFirstName, EmployeeLastName, p.ProjectID, ProjectName
FROM tblEmployees e, tblProjects p, tblEmployeeProjects ep
WHERE e.EmployeeID = ep.EmployeeID
AND p.ProjectID = ep.ProjectID
or the nasty looking Access genenerated version of the same query (INNER JOIN syntax should be outlawed):
Code:
SELECT tblEmployees.EmployeeID, tblEmployees.EmployeeFirstName, tblEmployees.EmployeeLastName,
tblProjects.ProjectID, tblProjects.ProjectName
FROM tblProjects
INNER JOIN (tblEmployees INNER JOIN tblEmployeeProjects
ON tblEmployees.EmployeeID = tblEmployeeProjects.EmployeeID)
ON tblProjects.ProjectID = tblEmployeeProjects.ProjectID;
and generate a single report which uses this query as its record source, like:
EmployeeProjectReport
Code:
EmployeeID EmployeeFirstName EmployeeLastName ProjectID ProjectName
1 John Doe
1 Project1
2 Project2
3 Project3
2 Jane Doe
1 Project1
2 Project2
3 Jed Doe
1 Project1
The Access report wizard will kick out this format for you is you give it the query above.
Just a thought anyway. Your sub-report filtering approach seems like a bit of a work-around for what appears to be a table schema design issue. I'm not sure I can offer any further codeing suggestions without a better handle on how you set up your tables and what your object record sources are.
HTH,
Bob