Results 1 to 11 of 11
  1. #1
    shuddle is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    53

    One Query result from two Tables with one similar field

    I have two tables: LookupTbl_Rates and Tbl_Vehicle_Data

    LookupTbl_Rates
    LK_Rate_ID
    LK_Tag
    LK_Monthly_Rate
    LK_Mileage_Rate
    LK_OE_Monthly
    LK_OE_Mileage

    Tbl_Vehicle_Data
    VehicleID
    TAG
    (plus other fields)




    What I am trying to do is get the results in a query

    VehicleID LK_Tag, LK_Monthly_Rate, LK_Mileage_Rate, LK_OE_Monthly, LK_OE_Mileage


    I have the relationship between TAG and LK_Tag set.

    The query I created will give the VehicleID or the LK values but not both.

    I think I'm making it to complicated. Any help is appreciated.

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,931
    What is the sql to your query?

  3. #3
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    565
    the one part you left out is the only part we need:
    on what columns are you joining the two tables?

  4. #4
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    on what columns are you joining the two tables?
    Would that not be
    I have the relationship between TAG and LK_Tag set.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,820
    Hi
    I think you need to add the following field "LK_Rate_ID" as a FK to your tbl_Vehicle_data

  6. #6
    shuddle is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    53
    Here is my Sql
    SELECT Tbl_Vehical_Data.VehicleID, Tbl_Vehical_Data.TAG, LookupTbl_Rates.LK_Rate_ID, LookupTbl_Rates.LK_Tag, LookupTbl_Rates.LK_Monthly_Rate, LookupTbl_Rates.LK_Mileage_Rate, LookupTbl_Rates.LK_OE_Monthly, LookupTbl_Rates.LK_OE_Mileage
    FROM Tbl_Vehical_Data LEFT JOIN LookupTbl_Rates ON Tbl_Vehical_Data.[TAG] = LookupTbl_Rates.[LK_Tag];


    Ultimately I need the query to connect the vehicle ID to the rates. The rates changes. The vehicle ID and TAGs will not.

    I will be overwriting new data into the LookupTbl_Rates each month which will change the LK_Rate_ID so I can't use that as a connector. I thought I could connect it on the tag number since it is constant.

    This may not be doable the way I am wanting it to work.

  7. #7
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,820
    Hi
    Your "LookupTbl_Rates" should have 2 additional fields "DateFrom" & "DateTo"

    Then when you use a Combobox to select a Rate you would filter to only show Rates which do not have a DateTo.

  8. #8
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Quote Originally Posted by shuddle View Post
    I will be overwriting new data into the LookupTbl_Rates each month which will change the LK_Rate_ID so I can't use that as a connector. I thought I could connect it on the tag number since it is constant.

    This may not be doable the way I am wanting it to work.
    I wouldn't overwrite this data. You can store the rate changes with valid from and to dates each time they change.
    This means you can always look up the correct rate based on the transaction date.

    It's much more robust method.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  9. #9
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,931
    In your Tbl_Vehical_Data table design is TAG a lookup field?

  10. #10
    shuddle is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    53
    I found another solution to get the results I needed. I used a ME statement to autofill the rates into the main table. It works. Thanks for your help.

  11. #11
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Quote Originally Posted by shuddle View Post
    I found another solution to get the results I needed. I used a ME statement to autofill the rates into the main table. It works. Thanks for your help.
    Can you show us, Me. isn't a function it's a way of referring to the current form object.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. One or two tables of similar data
    By Ant_Snell in forum Database Design
    Replies: 2
    Last Post: 02-15-2022, 07:12 AM
  2. Replies: 3
    Last Post: 08-22-2018, 11:05 AM
  3. Replies: 3
    Last Post: 03-01-2017, 02:46 PM
  4. Replies: 1
    Last Post: 02-23-2017, 09:09 AM
  5. Replies: 4
    Last Post: 08-01-2016, 06:41 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