Reputation: 747
I find that examples are the best way to describe problems in relation to rdms so I'll dive straight into a (fairly contrived) one.
I have a fruit-store table and a fruit table. I have built a user interface (form) for the greengrocer (who owns a chain of such stores, and intends buying many more) so that he can easily fill in the details concerning his stores, and the fruit that can be sold in them.
Each fruit has its own unique ID, as does each store. However fruit is not limited to any particular store, but may be sold in any number.
As such there is an intermediate table storeFruit which enables a many-to-many relationship between the store and fruit.
The greengrocer wants to be able to list out the stock (which consists only of fruit) of his store as he is putting in the other details about the store, like the address and phone number. Consequently there is a field in the form to list the fruit contained within the store. The only thing it has to do in the fruit table is correlate the fruit with the relevant store.
I have created a combobox which displays a particular fruit, but the field has no bearing on any table. Indeed, if you select banana and move to the next store in the form, banana will stay in the field, highlighting how it has no bearing on the information input. I have also created a subform (fruit), but this does not allow the ability to pick from a predefined list... it will end up with lots of "unique" (as in unique Fruit_ID) apples, pears, etc, as they are merely appended to the table. fruit essentially represents a predefined list.
So how might I bind this combobox such that it updates the required fields properly, and thus alleviate the stress of my fictional flummoxed greengrocer?
PS: looking at the diagram I realise that the stock column in the store table will never actually be used due to the nature of the relationships - but I created these tables and relationship diagram on the fly without saving, as I won't ever be using them, so it's too late to rectify it now!
Upvotes: 2
Views: 2353
Reputation: 91356
The usual way to set this up is with store in the main form and storeFruit in the subform. The link child and master fields should be set to store_ID. The_fruit_in_question becomes a combobox with a row source set to fruit ( select fruit_ID, fruit from fruit ), the bound column is 1 and the column widths are, say, 0, 2cm.
Upvotes: 1