简体   繁体   中英

How do I limit the items in a “List Box” column based on another column's input in a table in MS Access?

I tried setting up a relationship although I don't know if this is how I'm meant to do it: 我尝试建立关系,尽管我不知道这是我的本意。

Category column settings: 类别列设置

Description column settings: 说明列设置

Linked to the table that contains different type of furniture, "Furniture": 链接到包含不同类型家具的桌子“家具”

Furniture design: 家具设计

So what I want to do, is make it so that when you choose a furniture category, you can only choose from furniture descriptions of that category:

因此,我想做的就是选择一个家具类别时,只能从该类别的家具描述中进行选择...但是此刻,它显示了所有描述:

I do not think this can be done using only tables — you'll have to create a form that will limit the selection in the descriptions listbox based on the category.

Also, there are a number of problems with your data structure:

  • I imagine multiple Furniture s can have the same CATEGORY . This means that CATEGORY cannot be the primary key -- a uniquely identifying piece of data -- for Furniture . I would suggest adding a Long number column called FurnitureID . If you make this an Autonumber column, every new record will get a new number by default; otherwise you'll have to insert the number by hand.
  • Once you have such a column, you should have a corresponding column — AKA the foreign key column — in Stock of the same type (or Long if the FurnitureID is an Autonumber ). These two columns should be related in the Relationships window. The relationship means that every 1 Stock record must have a related Furniture record with the same data in both records.
  • Once you've done that, there is no need to repeat the CATEGORY and DESCRIPTION fields between the Stock and Furniture tables. This means no duplicate data, and no potential conflicts.

1. Depending on how the column is defined, it might be possible to have no data in the foreign key column in the Stock record; but this is relatively uncommon

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM