Results 1 to 3 of 3
  1. #1
    Thompyt is offline Expert
    Windows 10 Access 2016
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839

    How to reference data another lrow

    Lodging: Switch(([Sleg]=1 And [Sleg]=[Eleg]),[TDYDay]*[PD_Lodging],[Sleg]>=1 And [Eleg]>=2,([TDYDay]-1)*([PD_Lodging])+(DLocal [PD_Lodging]),([Sleg]>2 And [Eleg]>2) And [Sleg]=[Eleg],([TDYDay]-1)*[PD_Lodging])

    Sleg = Start Leg
    ELeg = End of leg in trip id multiple destination, or final leg in 1 leg trip
    PD_Lodging = Per Diem Loging costs per GTA
    TDYDay = the length of the trip gotten from the (stop day of trip - the start day) +1
    Olocal = Origin location
    Dlocal = Destination location

    Single leg trip is easy

    On a multiple leg trip, the last day of the previous leg changes the PD_Lodging cost to where you put your head down that night or Dlocal

    So if there is more than 1 leg then the last day of that leg will be the Dlocal PD_Lodging.



    Leg 1 of 2 example
    (TDYDay-1)*Olocal PD_Lodging + Dlocal PD_Lodging

    TDYDay = 6
    Olocal PD_Lodging for 5 days + 1 day of DLocal PD_Lodging

    Quick query
    Code:
    SELECT TBL_Consolidate.CON_ID, TBL_Consolidate.OLocale, TBL_Consolidate.Dlocale, TBL_Consolidate.SLeg, TBL_Consolidate.ELeg, [TDYStop]-[TDYStart]+1 AS TDYDay, TBL_Location.PD_Lodging, Switch(([Sleg]=1 And [Sleg]=[Eleg]),[TDYDay]*[PD_Lodging],[Sleg]>=1 And [Eleg]>=2,([TDYDay]-1)*([PD_Lodging]),([Sleg]>2 And [Eleg]>2) And [Sleg]=[Eleg],([TDYDay]-1)*[PD_Lodging]) AS LodgingFROM TBL_Location INNER JOIN TBL_Consolidate ON TBL_Location.LOC_ID = TBL_Consolidate.LOC_ID;

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Review http://allenbrowne.com/subquery-01.html#AnotherRecord

    If data is in other db platform like SQLServer, there are intrinsic functions to accommodate this requirement.
    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.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Provide some example data and the outcome required from that example data

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

Similar Threads

  1. Replies: 3
    Last Post: 05-17-2022, 10:36 AM
  2. Replies: 5
    Last Post: 07-10-2018, 09:53 AM
  3. Data Entry & Multiple Table Reference
    By dr4ke in forum Access
    Replies: 14
    Last Post: 06-22-2012, 08:23 AM
  4. Replies: 1
    Last Post: 06-18-2011, 10:00 AM
  5. How to reference data without using Dlookup()
    By HunterEngineeringCoop in forum Programming
    Replies: 7
    Last Post: 12-01-2010, 09:22 AM

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