Question : Dynamically creating relational tables / values...

I'm building an application in Access which I will need to add/remove combo-box elements from dynamically.  The elements saved to a table.  Now that's not the tough part... this is where it gets complicated.

In the application, the user has a form where they will create a record. (a ticket).  For each record, they will have to store why the ticket is created, by selecting items from a combobox, which will determine the values in another combobox.  However, they may have to store up to 3 'reasons' why the ticket was created.

So it'll work like this:

The user creates the ticket.  They will then select a Main Heading from the combobox, (for example, it may say "Customer Information").  Then they will select what about "Customer Information" caused the problem. (for example, it may say "Address is Incorrect".)  Once they select that, they will click "Add to Ticket" which will then associate the Reason with the record.  They may then go through the process again to add another "Reason" why the ticket is being created.  They may go through this process multiple times and add many "Reasons" to each Ticket.

I will store the combobox elements in two tables... the Major Reason (i.e. Client Information), and Detailed Reason (i.e. Address is Incorrect) will go in separate tables I assume.  I do not know how to relate these in the form, so if I choose a Major Reason ComboBox1, the corresponding Detailed Reason will show up in ComboBox2.  (or should this be stored on the same table?)

I do not know how to store this in the record to return the correct Major/Detailed reasons with a query---since there can be any number of Major/Detailed reasons associated with the record.  I assume each Major reason and Detailed reason will have it's own ID # Key?  But that will only work (to my knowledge) for a one-to-one relationship.  How do I build this?  Do I need one of those "connecting" tables which just contains which record is associated with which Reason #'s?

And lastly, the items in the Comboboxes (and the relationships) can change at anytime, so I need to create a way to "Add" or "Remove" items and relationships from the Comboboxes from the form.  The difficult part to this I assume is dynamically creating the relationship of "New Major Reason" (ComboBox1) with "New Detailed Reason" (ComboBox2)... no idea where to start here.

For example, one day I may decide to add a new Major reason, then add/remove the items associated with it.  Or add/remove Detailed reasons ComboBox2 from an existing Major reason ComboBox1.

Answer : Dynamically creating relational tables / values...

A simpler approach uses these tables:
tblTicket(TicketID, etc)
tblTicketReason(TicketID, MajorReasonID, MinorReasonID)
tblMajorReason(MajorReasonID, MajorReason)
tblMinorReason( MinorReasonID, MajorReasonID, MinorReason)

Compared with koutny's approach there may be a little more redundancy - the same minor reason text could be repeatedly stored in tblMinorReason for different major reasons - but it might be easier to work with.

You then need only one subform to add rows to tblTicketReason. It needs a combobox for the Major Reason ID with tblMajorReason as its source and a combobox for Minor ReasonID with tblMinorReason as its source, but this time filtered on the current value of the major reason combobox. In the afterUpdate event of the major reason combobox put a requery of the minor reason combo:

Me.cbMinorReason.Requery

You'd then need a separate form/subform to maintain tblMajorReason and tblMinorReason
Random Solutions  
 
programming4us programming4us