List boxes

david123

Registered User.
Local time
Today, 12:55
Joined
Feb 17, 2009
Messages
18
Hello,
I have a form with two listboxes, one which holds the names of positions and another that holds courses. Each of these is based on a parent table. I have a PositionCoursestbl which stores what courses are required for each position.

In my form, the user selects at least one position to edit and one course required for it. My issue is this: When I select at least one position and more than one course requirement, the table only gets updated with one record - the position and the last course selected. Ex. I select Accountant for the position and Course 1 and Course 2, the data stored in the table is Accountant and Course 2.

How can I have it so all the courses get updated? And how can i do this is more than one Position is selected (Multiple selections from both list boxes)?

Any help would be appreciated

Thanks,
David
 
You have to loop the listbox selected items when the listbox is multiselect. Here's an example:

http://www.baldyweb.com/MultiselectAppend.htm

Thanks for your reply. I tried to apply this method to my listboxes, but it would still only add the last selection in the list.

This is the code I used:

For Each varItem In Me.List8.ItemsSelected
strPosition = Me.List8.ItemData(varItem)
strCourses = Me.List4.Value
strSQL = "INSERT INTO PositionCoursestbl ([Position], [Courses for Position])" & _
" VALUES ('" & strPosition & "', '" & strCourses & "' );"
Next varItem

The user should be able to select multiple positions, but only one course at a time. Meaning for each position selected, a record would be added including the name of each position and the name of the one course selected.

Any ideas on why this is only adding the last position?

Thanks
 
Thanks for your reply. I tried to apply this method to my listboxes, but it would still only add the last selection in the list.

This is the code I used:

For Each varItem In Me.List8.ItemsSelected
strPosition = Me.List8.ItemData(varItem)
strCourses = Me.List4.Value
strSQL = "INSERT INTO PositionCoursestbl ([Position], [Courses for Position])" & _
" VALUES ('" & strPosition & "', '" & strCourses & "' );"
Next varItem

The user should be able to select multiple positions, but only one course at a time. Meaning for each position selected, a record would be added including the name of each position and the name of the one course selected.

Any ideas on why this is only adding the last position?

Thanks

Nevermind, I got it working now.
Thanks for the help!
 

Users who are viewing this thread

Back
Top Bottom