Results 1 to 8 of 8
  1. #1
    dominover is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    11

    Just cannot understand lookup tables?

    I thought I understood lookup tables but it appears that I'm even more confused than ever.


    For example. Please see below for final comments.

    Here is my table. I want to create a lookup combo box in Field2
    Click image for larger version. 

Name:	table.png 
Views:	32 
Size:	8.9 KB 
ID:	23898


    I use the settings as shown below.
    Click image for larger version. 

Name:	settings_lookup.png 
Views:	32 
Size:	17.2 KB 
ID:	23899

    But, when I select the combobox values I get the below result. See how the field names appear in the combobox.
    I have selected column 3 (Field 2) to be bound to the combobox in Table1. I have chosen only 1 value to be displayed.
    Why is this happening??? I am clearly misunderstanding lookups!

    I have a similar problem when I select Table/Query as the Row Source Type. If I'm using a whole table as my lookup table and I select the bound column to be 3 and the number of visible columns to be 1 then I should get the result I'm looking for but instead I can only get the ID Field? Again, I have clearly misunderstood lookups!

    Click image for larger version. 

Name:	result.png 
Views:	32 
Size:	9.9 KB 
ID:	23900

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    They are simply a level of indirection and generally avoided by most developers since they can easily confuse the programmer. Using "lookup's" (comboboxes) on a form are just fine and the preferred design. Using Lookup Fields in a table hides what is really in the table.

  3. #3
    dominover is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    11
    Quote Originally Posted by RuralGuy View Post
    They are simply a level of indirection and generally avoided by most developers since they can easily confuse the programmer. Using "lookup's" (comboboxes) on a form are just fine and the preferred design. Using Lookup Fields in a table hides what is really in the table.
    Hmm. But that that's where I'm at. Confused..

    Can anyone answer this?

  4. #4
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    let me try and explain what ruralguy is saying. most programmers don't care to know that much about lookup fields because they break rules of normalization. combo boxes on a form display a easy to read value but store a single repetitive value in the table, good storage technique. lookup fields in a table break this rule by displaying a easy to read value in the form but store a unnecessary text field in the table that could have been accomplished with the number "1" or "3", bad storage technique. if you're interested take a look here for some good information.
    http://www.rogersaccesslibrary.com/f..._topic238.html

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664

    How to create a combo box for a Look up *TABLE*.

    Create a new table.
    Add these fields

    Field name
    FieldType
    ColorID_PK Autonumber (PK)
    ColorName Text

    Set the field "ColorID_PK" as the primary key field.
    Save the table as "tblColors".

    Add these colors to the table.
    Red, Blue, Yellow, Black, White, Pink

    --------------------------------
    Create a new table.
    Add these fields
    Field name
    FieldType
    AutoID_PK Autonumber (PK)
    ColorID_FK Number (Long) (FK to tblColors)
    AutoMake Text
    AutoModel Text

    Set "AutoID_PK" as the primary key field.
    Save the table as "tblAutos". Add these to the table
    Make Model
    Chevy Corvette
    Chevy Camero
    Chevy Serria
    Honda Accord

    --------------------------------
    Create a query.
    The SQL looks like:

    SELECT tblAutos.AutoID, tblAutos.AutoMake, tblAutos.AutoModel, tblAutos.AutoColor_FK
    FROM tblAutos;

    Name the query "qryAutos"

    --------------------------------
    Create a new form.
    Open the properties window for the form.
    Click on the DATA tab.
    In the RECORD SOURCE property, select "qryAutos".

    In the FORMAT tab, change the "Default View" to "Continous Forms".

    Right click to highlight "DETAILS". In the menu, select "FORM HEADER/FOOTER"
    Add the fields to the DETAILS section.

    I click on the Deaign in the menu and click on "Add existing fields". Drag the fields to the DETAILS section. Or you can select them all and drag them.
    Select all of the labels and cut them, then paste them in the form header section.
    While the labels are selected, click format and change teh font to black.

    Arrange the control in a horizontal line at the top of the detail section. Arrange the labels in the header section to be above the associated controls.
    Drag the FORM FOOTER up to just below the controls.

    Save the form as "frmAutos".

    --------------------------------
    Open the RELATIIONSHIP WINDOW
    Add the table "tblColors" and "tblAutos"
    Drag the "tblColors" PK field (ColorID_PK) to the "tblAutos" FK field (ColorID_FK). check "Enforce Referencial Integerity". Close and save the window.

    --------------------------------
    --------------------------------
    Now we are ready to create a combo box to look up a color.

    Open the form in design view.
    Right click on the "ColorID_FK" control.
    Hover over the "Change to" option, then select "Combo box".
    Double click on the combo box to open the properties window.

    Click on the DATA tab.
    Click in the "ROW SOURCE" property.
    Click on the ellipse (the 3 dots). Add "tblColors" to the design grid. Drag down the fields "ColorID_PK", then "ColorName" (in that order)
    Close and save the query.

    Settings:
    The "ROW SOURCE" property should be "Table/Query"
    The "Bound Column" should be 1. (the first field in the query you just created for the "ROW SOURCE" property)
    Click on the FORMAT tab.
    Set the 'Column Count" TO 2.
    sET THE "COLUMN WIDTHS" to 0,1

    Save the form

    Open Form1.
    You should see the list of Makes and Models, but no colors.
    Click on the color combo box for the Camaro. Select "Blue".

    Close the form.
    Open the table "tblAutos".
    You should see a number in the color field. Remember the number.
    Open the table "tblColors". Find the number. The color name should be "blue".


    Congratulations!! You have just created a look up to a table!



    --------------------------------
    --------------------------------
    One more thing...........

    The "ROW SOURCE" property of the combo box has 3 options:
    1) "Table/Query" - you can pick a table, a saved query or creat an SQL string
    2) "Value List" - you type in the values you want to have available.
    3) "Field List" - displays the names of the fields in the "Row Source". If you select "tblColors" as the row source, the field list would be "ColorID_PK" and "ColorName". You would be able to only select "ColorID_PK" or "ColorName".

  6. #6
    dominover is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    11
    Thanks for the effort. It wasn't the question but no doubt this will come in handy.

  7. #7
    NTC is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    if you bound column is 3; then your 'column widths' property would be: 0,0,1 (1 is width - it can be any number)

    actually it may need to be 0,0,0,1 .... I believe the count left-to-right begins with 0 so if you bind the 3rd column then its visibility is the 4th sequentially in the column width property.... can't remember at the moment

    what you could do is consider also is in row source - press the ellipses ... and turn it into a query that just contains the field you want; and then your bound field and visible field are the same as there is only 1 field in the record source.

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    dominover,

    To add to the info you have already been given, you are dealing with 2 subjects which sound similar but are different.

    A Lookup Table is a separate entity that contains a code and some associated information.

    example:
    UN Countries or areas, codes and abbreviations

    This table uniquely identifies Countries or Areas and associates its English Name and the ISO-3166-2 standard 3 character abbreviation.(see attached jpg)

    This would be held as a separate table. In any other tables using a Country, the UN numerical code would be a foreign key to the record in this table. To do a lookup of the CountryName, given its numerical code, you would/could use a query.

    In a situation using a form, you could have this Lookup table as the rowsource of a combo box. When the user opens the combo, s/he is presented with a list of CountryNames. The idea in this instance is that you have a reference list of Countries and codes. If you design to use such a Lookup Table you will not have spelling mistakes/typos in the CountryNames.

    a description from "googling"

    A lookup table is normally a table that acts as a "master list" for something and you use it to look up a business key value (like "Make") in exchange for its identifier (like the id column) for use in some other table's foreign key column.

    Basically, you come in with something to "look up" and exchange it for something else.

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

Similar Threads

  1. D lookup between two tables
    By punna111 in forum Access
    Replies: 5
    Last Post: 03-26-2015, 09:19 AM
  2. Use of Lookup Tables
    By Saint in forum Access
    Replies: 1
    Last Post: 03-05-2012, 11:49 PM
  3. lookup tables
    By nkuebelbeck in forum Forms
    Replies: 3
    Last Post: 03-15-2010, 02:10 PM
  4. Lookup Tables
    By corinthianw in forum Access
    Replies: 1
    Last Post: 02-17-2010, 01:31 PM
  5. Lookup Tables
    By JoeBio in forum Database Design
    Replies: 1
    Last Post: 09-01-2006, 07:34 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