Retrieve values from table back into my listbox?

qdogfball

Registered User.
Local time
Today, 11:13
Joined
Jul 24, 2007
Messages
65
Ok, I have read many posts on multi-select list boxes and thought that the correct way to handle things is a one-many table.

So here is my problem.

I have a table that is populated by a listbox. The multi-selections go into the many table correctly.

But if I change records, and come back, the listbox of course does NOT bring back the items that were put into the many table. The listbox shows the items that can be selected, but there is nothing selected from before.

If I click on new items, they go into the many table too.

The listbox is in a subform, related to my main form based on PO# and Store # (they are the unique items to relate to.)

The listbox items that you can select are from a table ProperAttachments, the Listbox selections are stored in (Record Source) tblAttachments.

The subform for the listbox has the following properties:
Control Source = tblAttachments.Attachments
Row source type = Table/query
Row source = ProperAttachments
Multi-Select = Simple
View = Datasheet

If I need to give more information, please let me know.

I must be missing something simple (I hope!) :o
 
Have the items in your 'many table' been lost, or is it that the highlighting of the items previous chosen is no longer there?

If it is the former then it sounds like the table is not storing the values but if the latter you perhaps need to run some code to refresh the selected items in the list box.

Sorry that I can't help much more on this, I've never used a multi-select list box.

Tim
 
Thanks Tim for replying.

For your question, it is the latter. The information is being stored correctly in the table.

But I think that for the code:

I will have to make an on current event on the form to check and see if there are any values in the many table that match the keys.

If there are values, populate a listbox with the values.

Similar to this post:
http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=52736

but, then I need the ability to erase/update the information from the listbox and the many table, if someone updates the information in the listbox again! :(
 
Smacks Head with Hand! :eek:

Sigh..

Sometimes you just try to get TOO tricky and it works against you!

My solution was relatively easy.

1. Create an Auto number for a Primary key to make the one-many relationship work correctly.

2. Create the subform with the many table and use a combobox to display the records you can pull from. The subform displays in Datasheet view.

3. In the main form, make the table link via the Auto number and a number in the many table.

So, instead of a list box, creating a subform with a one-many relationship was SO easy! :D
 

Users who are viewing this thread

Back
Top Bottom