Results 1 to 2 of 2
  1. #1
    tomeratz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Posts
    1

    vlookup in a query

    hi there
    i have 3 tables

    Emp_tbl
    EmpID EmpName
    1 A
    1 B

    SalToEmp_tbl
    EmpId EmpHourelyRate EmpSalChangeDate
    1 20 01/01/2015
    2 21 01/01/2015
    2 23 01/03/2015

    HouresDb_tbl
    EmpID WorkDate WorkDateHoures
    1 02/01/2015 8
    2 04/01/2015 7
    1 08/02/2015 5
    2 21/02/2015 8
    2 01/03/2015 8
    1 05/03/2015 5
    2 30/03/2015 6
    2 02/04/2015 8.5

    both the last two Joined to the first table with EmpID field.

    my request for help:


    i'm trying to creat the folowing querie

    EmpName WorkDate WorkDateHoures EmpSalChangeDate EmpHourelyRate DaySal
    A 02/01/2015 8 01/01/2015 20 160
    B 04/01/2015 7 01/01/2015 20 140
    A 08/02/2015 5 01/01/2015 20 100
    B 21/02/2015 8 01/01/2015 20 160
    B 01/03/2015 8 01/03/2015 23 184
    A 05/03/2015 5 01/03/2015 23 115
    B 30/03/2015 6 01/03/2015 23 138
    B 02/04/2015 8.5 01/03/2015 23 195.5

    the EmpSalChangeDate field needs to be <= WorkDate Filed, and show the lower closest date.
    I use Access 2010 windows 7 ultimate.

    thanks

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    Join all three tables on EmpID and in your criteria for SalToEmp_tbl.EmpSalChangeDate put
    Code:
    (SELECT Max(EmpSalChangeDate) FROM SalToEmp_tbl AS T WHERE EmpID=SalToEmp_tbl.EmpID AND EmpSalChangeDate<=WorkDate)

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

Similar Threads

  1. Replies: 8
    Last Post: 02-03-2015, 12:49 PM
  2. Replies: 2
    Last Post: 10-09-2012, 03:20 PM
  3. Replies: 5
    Last Post: 08-13-2012, 01:25 AM
  4. Query to work as a Vlookup function
    By dharmik in forum Queries
    Replies: 21
    Last Post: 01-04-2012, 08:12 AM
  5. Access equiv to the vLookup in a Query
    By Scorpio11 in forum Queries
    Replies: 10
    Last Post: 07-07-2010, 11:36 AM

Tags for this Thread

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