Results 1 to 6 of 6
  1. #1
    Torchwood is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    6

    Newbie Question: How to make a table lookup field depend on value in another column

    Hi - I'm new here, and very new to Access. I'm pretty experienced with Excel and VBA, but have come across a problem at work that I know really needs to be solved using Access - so time for me to learn! I'm Googling for as much as I can, but I'm going to get stuck quite a few times with probably simple things! Thanks for your patience ...



    (Using Windows 7, Access 2010 btw)

    Q1

    Say I have a table called Locations that lists Countries and Cities:

    USA, Detroit
    USA, Chicago
    USA, New York
    UK, London
    UK, Liverpool
    UK, Birmingham
    France, Paris
    France, Le Mans

    I then have another table for inputing details on people I know. This table would have columns called Country and City. I've figured out how to make the Country column a "lookup column" so that I can only enter USA, UK or France. But how do I make the City column show only the appropriate list of cities relevant to the country that I've selected (e.g. Paris or Le Mans if France is the selected country).

    Thanks!

    Q2 to follow later

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    In a form you'd use cascading combos:

    Baldy-Cascading Combos

    By the way, most of us dislike the lookup field in table design:

    http://access.mvps.org/access/lookupfields.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Torchwood is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    6
    Great - thanks Paul. I had played with a Form previously, and got the 2 combo boxes to sort of work, but couldn't get the second to update when the first was changed ... I can see how your code fixes that

    Interesting article on lookup fields. I'm assuming principle is to have users input their data using forms and not directly into the tables themselves. Then, the form to provides the control and validation of the entered data; i.e. we don't have this control embedded directly into the table itself.

    As I'm just starting out with all this, I can easily avoid the use of lookup fields right from the start ...

    EDIT: Ah! The 10 Commandments of Access #2
    Last edited by Torchwood; 09-20-2012 at 10:47 PM. Reason: Bad grammar!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help, and welcome to the site! Most experienced developers, myself included, never let users into tables or queries, only forms and reports. you have virtually no control if they are in the table directly.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    smithse is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    37
    Quote Originally Posted by pbaldy View Post
    Happy to help, and welcome to the site! Most experienced developers, myself included, never let users into tables or queries, only forms and reports. you have virtually no control if they are in the table directly.
    Hey pbaldy,

    Yes, not letting users into the 'heart' of the system requires about 10-fold the number of hours of development... but it pays off! I'd rather write all those nasty SQL statements than bind forms! Yuck! LOL

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Most of my forms are bound; why not let Access do most of the work? In limited circumstances, I do use unbound forms. Jason has a decent discussion of the issue here:

    http://www.baldyweb.com/BoundUnbound.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Lookup column based on table value
    By greenkevin86 in forum Access
    Replies: 9
    Last Post: 04-30-2012, 06:03 PM
  2. Set textbox field to depend on current date
    By lilanngel in forum Queries
    Replies: 6
    Last Post: 03-10-2011, 08:16 AM
  3. Lookup column relating items in same field
    By rmroberts76 in forum Access
    Replies: 8
    Last Post: 06-05-2010, 07:41 PM
  4. Replies: 5
    Last Post: 08-05-2009, 12:13 PM
  5. Adding new column to make-table query
    By dtn118 in forum Access
    Replies: 2
    Last Post: 08-03-2008, 06:51 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