Connecting historical data

johannaellamay

Registered User.
Local time
Today, 16:37
Joined
Jul 19, 2014
Messages
190
Hello, I'm a real newbee so please be forgiving. This will be a long post because I want to explain the details.

This is the situation that I'm stuck with:

I have the following tables

1. t_Employee. It consists of the following fields:

  1. EmployeeID
  2. Name
  3. Job Title
  4. Contract Start Date
  5. Contract End Date

2. t_Login. It has the ff fields:

  1. UserID
  2. UserName
  3. Password

3. t_AuditTrail w/ the ff fields (this will used for historical data for Job title, Contract Start Date, Contract End Date, etc.):

  1. AuditTrailID
  2. TableID (in this case t_Employee)
  3. FieldName (JobTitle)
  4. RecordID (EmployeeID)
  5. OldValue
  6. NewValue
  7. ChangeDate (date edited)
  8. ChangeBy (UserName)

I've already set up t_AuditTrail by putting several (& separate) After Update Data Macros.

attachment.php


Now, I have a form for t_Employee. It has a button that would open a report. This report contains the Job Title history of an employee.

The report is based on a query w/ the ff SQL:

Code:
SELECT t_AuditTrail.atTableID, t_AuditTrail.atFieldName, t_AuditTrail.atRecordID, t_AuditTrail.atOldValue, t_AuditTrail.atNewValue
FROM t_AuditTrail
WHERE (((t_AuditTrail.atTableID)="t_Employee") AND ((t_AuditTrail.atFieldName)="eJobTitleID"));

So the report only shows historical data for Job Title. Which means that Job Title from t_AuditTrail is not related to Contract Start Date or Contract End Date.

Problem(s)/Question(s):I want my report to show the Job Title History and the corresponding contract start date and contract end date (not the date a record was edited). When an employee changes a job title, his/her contract dates change.However, when i start to make a report based on quesries q_AuditTrail_JobTitle and q_AuditTrail_ContractStartDate and q_AuditTrail_ContractEndDate, Access tells me that they are not connected so it cannot make a report. How do I go about this? How do I let user see the Job Title relative to its contract start and end dates?

Please help. I'm stuck. :( I hope I've laid out the details well enough.
 

Attachments

  • audit.jpg
    audit.jpg
    89.1 KB · Views: 304
I think this is what you are looking for...

Code:
SELECT t_AuditTrail.atTableID, t_AuditTrail.atFieldName, t_JobTitle.jtJobTitle, t_Employee.eContractStartDate, t_Employee.eContractEndDate, t_AuditTrail.atRecordID, t_AuditTrail.atOldValue, t_AuditTrail.atNewValue
FROM t_JobTitle RIGHT JOIN (t_AuditTrail LEFT JOIN t_Employee ON t_AuditTrail.atRecordID = t_Employee.eEmployeeID) ON t_JobTitle.jtJobTitleID = t_Employee.eJobTitleID
WHERE (((t_AuditTrail.atTableID)="t_Employee") AND ((t_AuditTrail.atFieldName)="eJobTitleID"));
 

Users who are viewing this thread

Back
Top Bottom