I need to query three tables – Employee, ADPHours, and PayJournal. Each entry in ADPHours
and PayJournal will have an EmployeeID that will match an EmployeeID in the Employee table.
Some employees will have entries in both ADPHours and PayJournal. Some will have an entry
in only one of those two tables.
I would like my query to select a field called DailyHrs from the ADPHours table and ProcessPay
from the PayJournal table plus the employee information from the Employee table. Some of the
records created by the query will have values for both DailyHrs and ADPHours. Some will have an
entry in only one.
The query needs to match the tables on EmployeeID and date parameters passed from a form.
A simple query (what I consider a simple query) on all three tables will only create a record for an
EmployeeID if there is a matching EmployeeID and date in all three tables. I need to create a record
from the query even if there is only matching criteria in either the ADPHours or the PayJournal table.
There will always be a matching EmployeeID in the Employee table. I don't really need an
entry from the Employee table if there are no matching entries in the other two tables.
Can anyone give me any tips on writing the query? It would basically be a combination of the two
queries below.
Thanks for any help.
and PayJournal will have an EmployeeID that will match an EmployeeID in the Employee table.
Some employees will have entries in both ADPHours and PayJournal. Some will have an entry
in only one of those two tables.
I would like my query to select a field called DailyHrs from the ADPHours table and ProcessPay
from the PayJournal table plus the employee information from the Employee table. Some of the
records created by the query will have values for both DailyHrs and ADPHours. Some will have an
entry in only one.
The query needs to match the tables on EmployeeID and date parameters passed from a form.
A simple query (what I consider a simple query) on all three tables will only create a record for an
EmployeeID if there is a matching EmployeeID and date in all three tables. I need to create a record
from the query even if there is only matching criteria in either the ADPHours or the PayJournal table.
There will always be a matching EmployeeID in the Employee table. I don't really need an
entry from the Employee table if there are no matching entries in the other two tables.
Can anyone give me any tips on writing the query? It would basically be a combination of the two
queries below.
Code:
PARAMETERS [Forms]![ExportPR].[txtStartDate] DateTime,
[Forms]![ExportPR].[txtEndDate] DateTime;
SELECT [Employee].[EmployeeID], [Employee].[LastName],
[Employee].[FirstName], [Employee].[Rate], [Employee].[Department],
([ADPHours].[DailyHrs]) AS Hours, [ADPHours].[SDate]
FROM Employee, ADPHours
WHERE ((([ADPHours].[SDATE])>=[Forms]![ExportPR].[txtStartDate]
And ([ADPHours].[SDATE])<[Forms]![ExportPR].[txtEndDate]+1)
And ([ADPHours].[EMPNUM])=[Employee].[EmployeeID])
ORDER BY [Employee].[Department], [Employee].[LastName],
[Employee].[FirstName], [ADPHours].[SDATE];
Code:
PARAMETERS [Forms]![ExportPR].[txtStartDate] DateTime,
[Forms]![ExportPR].[txtEndDate] DateTime;
SELECT [Employee].[EmployeeID], [Employee].[LastName],
[Employee].[FirstName], [Employee].[Rate], [Employee].[Department],
([PayJournal].[ProcessPay) AS PieceRate
FROM Employee, PayJournal
WHERE ((([PayJournal].[ProcessDate])>=[Forms]![ExportPR].[txtStartDate]
And ([PayJournal].[ProcessDate])
<[Forms]![ExportPR].[txtEndDate]+1) And ([PayJournal].[EmpID])=
[Employee].[EmployeeID])
ORDER BY [Employee].[Department], [Employee].[LastName],
[Employee].[FirstName], [PayJournal].[ ProcessDate];
Thanks for any help.