Book example – Building table entries from two combo boxes

5 pts.
Tags:
Access 2007
ComboBox
Visual Basic
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following