listbox textbox combination (1 Viewer)

wannabe

Registered User.
Local time
Today, 04:12
Joined
Feb 13, 2000
Messages
14
I have a table with over 700 records in it which I have in a list box so that I can maintain the integrity of my data. This table consists of the MCA Codes (Montana Code Anotated).
I have download a copy of code written by Ken Getz called With Events. This allows the user to start typing the charge in a textbox and as the user types it jumps through the list box as each letter is typed.
However, the user many times will need to select multiple charges that a defendant has committed. I have decided to use this combination as it would take too much time for the user to scroll through the list tyring to find all the records that they need. I have tried setting the listbox to multi-select but my textbox stop working.

Does anyone know of any way of dealing with this? I'm still fairly new at VBA so I would appreciate detailed information.


TIA
Emily
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 23:12
Joined
Feb 19, 2002
Messages
43,233
You have a one-to-many relationship. The proper way to manage this is to build another table. The table would contain two fields and both would be used to make up the new table's key - the same key that your main table uses and the charge. If there are three charges, you will add three rows to this table. This relationship would be shown as a subform. You would use a combobox for the charge field so that the choice could be picked from a list.

You can see an example of this type of structure in the northwind.mdb. The order form has a detail section where order items are entered and the product code is selected from a combobox.
 

Travis

Registered User.
Local time
Yesterday, 20:12
Joined
Dec 17, 1999
Messages
1,332
I concure with Pat. The main point is that a multiselect List Box does not have a single referenceable value and thus does not save any data to the table field it is linked to. Using a seperate table and adding its form as a subform to the main table you can easily add as many charges as you would like to a defendant. (Also the combo box has a property that alows the user to just start typing and it will take you to the closest match like Mr. Ken Getz code.)
 

Users who are viewing this thread

Top Bottom