Results 1 to 4 of 4
  1. #1
    Accessbegin is offline Novice
    Windows 10 Access 2013
    Join Date
    Nov 2015
    Posts
    2

    Query question

    Hi, I am a beginner learning MS Access in school.


    And I faced this problem while doing my project.

    The problem that I need to do is to create report based on the query I should create.
    The thing that I don't know is how to make a field in query to lookup(?) value that matches from another value.
    I am not sure if it quite makes sense but.. what I am trying to do is like:




    To make depature/arrrival city to lookup the value from another table "CITY" so that it will show city names instead of numbers.
    I am not sure if certain relationship is needed to make this work...

    Thank you
    Last edited by Accessbegin; 11-27-2015 at 12:17 PM.

  2. #2
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,929
    in your query query, drag the flights table on once and the cities table on twice (the second one will have _1 added to the end) from the navigation window.

    then create a link from departure city to the first city table by clicking on departure city and dragging to the matching field in the city table. Do the same for arrival city to the other city table

    now drag down to the grid at the bottom the fields you want in your report

  3. #3
    Accessbegin is offline Novice
    Windows 10 Access 2013
    Join Date
    Nov 2015
    Posts
    2
    Thank you very much.

    It worked perfectly. But why it doesn't work when there is only one city table (without city_1) if I may ask.. ?

  4. #4
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,929
    Not sure what you mean by 'it doesn't work...' You have two links to the same table but from different fields - so you have two copies of the table. Take one of the tables away and it will still work, but you can't report on data in the table you have removed.

    the table name .._1 is what is called an alias - open the properties for the table in the query window and you will see it there.

    Aliasing is a good habit to get into as you can make the names more relevant to the task in hand

    e.g.

    SELECT ... FROM citytable as departurecity....citytable as arrivalcity

    or cut down on the amount of typing

    SELECT ... FROM citytable as D....citytable as A

    particularly as many newbies insist on really long over descriptive table and field names, often with spaces

    [the data I got from excel last week].[interest after deducting tax]

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

Similar Threads

  1. Query question
    By jscriptor09 in forum Queries
    Replies: 2
    Last Post: 06-12-2013, 03:30 PM
  2. query question
    By jscriptor09 in forum Queries
    Replies: 10
    Last Post: 05-01-2013, 09:49 PM
  3. Sub-query question
    By hklein in forum Queries
    Replies: 1
    Last Post: 05-01-2012, 03:02 PM
  4. Query question
    By j2curtis64 in forum Queries
    Replies: 8
    Last Post: 07-29-2011, 01:45 PM
  5. Query Question
    By starhannes in forum Queries
    Replies: 13
    Last Post: 05-06-2010, 04:05 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