5 pts.
 Book example - Building table entries from two combo boxes
I have a DB for recording safety information. I have a form to document individual accidents. Each accident can cause multiple types of harm to multiple assets. In the accident form, I have a combobox where I can select a single asset and another where I can select its associated types of harm. Once I make these two selections, I would like a button to create a new record made up of the selected asset and its associated types of harm. I would like to be able to go through this process a number of times (selecting one assets and multiple harm types) until I have identified all of the types of assets the accident can harm including the different relevant type of harm. I am not sure the best way to organize tables to do this and I do not know how to write the VB code for the button that adds a new asset with its harm types. Note that different assets have different numbers of harm types.

I am totally new to VB and access and this is the hardest thing I have tried to do (as well as likely to be the hardest thing I need to do).

This is going into a book on safety (DB on CD) and I would be happy to acknowledge in the book the person who helps me solve this problem.

Software/Hardware used:
MS Access 2007
ASKED: Jun 24, 2011  7:44 PM GMT
UPDATED: June 27, 2011  1:49:16 PM GMT
1,740 pts.

Answer Wiki:
Rather than a button that uses VB to insert records, I would suggest that your accident form has subforms that are bound to the tables to automatically insert the records.

Yours tables may look like this:

Asset table - includes information about the assets. Combo boxes are bound to this tables for valid asset selection.

Harm table - includes all the harm that can be done to any asset. Combo boxes are bound to this table for valid harm selection.

Accident table - identifes the accident

AccidentAsset table - identifies the asset or assets that were harmed in the accident. With primary keys on Accident and Asset codes

AccidentAssetHarm table - identifies the harm caused to each asset in the accident with primary keys on Accident, Asset and Harm codes.

In the Accident form which is bound to the Accident table, a subform would be bound to the AccidentAsset table with parent/child link on the Accident code. Then, another subform inside of the AccidentAsset subform bound to the AccidentAssetHarm table with parent/child link on Accident and Asset fields.

With these forms bound to the tables, the insert of the records will be automatic. No VB code needed.
Last Wiki Answer Submitted:  Jun 27, 2011  1:49 PM (GMT)  by  Randym   1,740 pts.
To see other answers submitted to the Answer Wiki View Answer History.
Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _