问题
Hopefully this will make sense...I have a table in Access 2010 that contains a list of suppliers and their point of contacts at the supplier and where I work. The POCs vary in number, anywhere from 1-4 up to this point. The table is set up so each POC is on a separate line.
The supplier could have one contact but work could have three different contacts and vice versa.
What I want to happen is when I select a value from a combobox on a form, all the related POCs need to be shown instead of cycling through them one by one.
For example, Supplier1 has two POCs at their facility and we have three at our facility. I would like to have the combobox find Supplier1 in the table and then show all the contacts for that supplier (their facility and ours) in a textbox.
The user will be able to edit the contact information and, if it is not too difficult, would be able to add/delete a contact.
I'm sure a question similar to this one has been asked before, however I have been unable to word it correctly to find a solution through google searches/this website. I'm comfortable enough with VBA to use that if required but am by no means an expert. I am completely unfamiliar with SQL and would like to avoid going that direction if at all possible.
I have to be careful with any data I provide but will do what I can if you need to see the data or anything like that.
Supplier Code Part Supplier Contact Procurement Contact QC Contact
Ajin AKVN Patrick Yong Jack
Ajin AKVN Chase Yong Jack
Autoliv AMNP Seatbelt Daryl James Lewis
Bosch AG48 Hancheul Kevin
Carlex AKJ5 QTR Glasses Bob Joy Zack
Continental ANKC Jacob
KSR C03A05 Brake Pedal Jose Paul David
KSR C03A05 Brake Pedal Jose Paul Gary
KSR C03A05 Brake Pedal Jose Paul Steven
KSR AG5Z Accelerator Pedal Jack Paul David
KSR AG5Z Accelerator Pedal Jack Paul Gary
KSR AG5Z Accelerator Pedal Jack Paul Steven
KSR AG5Z Accelerator Pedal Cory Paul David
KSR AG5Z Accelerator Pedal Cory Paul Gary
KSR AG5Z Accelerator Pedal Cory Paul Steven
回答1:
Your table needs heavy normalization (see e.g. What is Normalisation (or Normalization)? or http://r937.com/relational.html )
I would suggest (Note: I'm not sure about the Supplier/Code/Part relation) :
- tSupplier
SupplierID SupplierName
1 Ajin
2 KSR
- tParts
PartID SupplierID Code Part
1 1 AKVN
2 2 C03A05 Brake Pedal
- tContactTypes
TypeID Type
1 Supplier
2 Procurement
3 QC
- tContacts
ContactID SupplierID TypeID ContactName
1 1 1 Patrick
2 1 1 Chase
3 1 2 Yong
4 1 3 Jack
and so on. The first column of each table is the primary key, an autonumber field. All other ID columns are foreign keys, linking to a parent table.
Now you can have a combobox for the Supplier, which gives the SupplierID.
With that, you can filter the Contacts and show them in a datasheet subform.
Either all in one table, with the ContactTypes as column, or in three subforms, each filtered by one ContactType.
To be able to add new contacts, use the BeforeInsert
event to assign the current SupplierID.
来源:https://stackoverflow.com/questions/32098889/show-all-records-for-given-field-filter-in-access-2010-table