Results 1 to 4 of 4
  1. #1
    cmoogy is offline Novice
    Windows 8 Access 2013
    Join Date
    May 2015
    Posts
    2

    Using most current employee wage rate

    Hello,

    I am setting up a time tracking database which will track employees maintenance times. Several employees spend X number of hours each day maintaining machines from different categories, such as mowing, snow removal, etc.

    I am trying to figure out if it is possible to set the tables up in a way which will not require adding an employees wage rate to every time tracking (listed in the time tracking table below) record. To somehow have the table pull data from the most recent wage record for that particular employee. As employees get raises I would like to retain the old rate in the time tracking table along with the new rate for current data.

    The way I have the tables setup right now are as follows.

    Employee table
    • EmployeeID
    • FirstName
    • LastName
    • Address, Phone, etc


    Maintenance Categories table
    • MaintID
    • MaintName


    Wage table

    • WageID
    • EmployeeID
    • DateEffective
    • CurrentWage


    Time Tracking table
    • TimeTrackingID
    • EmployeeID (lookup from employee table)
    • MaintID (lookup from maintenance table)
    • WageID (lookup from the wage table)
    • DateOfMaintenance
    • StartTime
    • EndTime


    All of the tables have relationships in the time tracking table.

    I will be grateful for any input. Thank you.

  2. #2
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    use a subquery in your criteria- something like

    Code:
    SELECT *
    FROM (tblEmployees INNER JOIN tblWages ON tblEmployees.employeeID=tblWages.employeeID) INNER JOIN tblTracking ON tblEmployees.employeeid=tbltracking.employeeid
    WHERE tblWages.DateEffective=(SELECT Max(DateEffective) FROM tblWages as T WHERE employeeID=tblWages.employeeID AND DateEffective<tblTracking.DateofMaintenance)

  3. #3
    cmoogy is offline Novice
    Windows 8 Access 2013
    Join Date
    May 2015
    Posts
    2
    Will try that out. thank you.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Have to find wage record that has the most recent date for each employee. This gets a little tricky and several ways to accomplish depending on where it needs to happen.

    Nested subqueries are one. Using TOP N parameter:
    http://allenbrowne.com/subquery-01.html#TopN

    Using domain aggregate in query:
    SELECT Employee.*, CurrentWage FROM Employees INNER JOIN Wages ON Employees.EmployeeID=Wages.EmployeeID WHERE DateEffective=DMax("DateEffective", "Wages", "EmployeeID=" & [EmployeeID]);

    Using domain aggregates in textbox expression:
    =DLookup("CurrentWage", "Wages", "EmployeeID=" & [EmployeeID] & " AND DateEffective=#" & DMax("DateEffective", "Wages", "EmployeeID=" & [EmployeeID]) & "#")
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 08-27-2014, 12:20 PM
  2. Replies: 1
    Last Post: 04-14-2014, 11:44 AM
  3. tracking multiple wage types
    By Helystra in forum Database Design
    Replies: 1
    Last Post: 10-31-2013, 11:23 AM
  4. Replies: 3
    Last Post: 07-25-2013, 11:35 PM
  5. Replies: 8
    Last Post: 06-06-2012, 12:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums